extended_nested_set 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.textile +3 -0
- data/Rakefile +0 -0
- data/lib/extended_nested_set.rb +2 -0
- data/lib/extended_nested_set/instance_methods.rb +37 -0
- metadata +60 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ExtendedNestedSet
|
2
|
+
module InstanceMethods
|
3
|
+
|
4
|
+
def is_first_of_siblings?(parent = nil)
|
5
|
+
if parent
|
6
|
+
parent.lft == self.lft - 1
|
7
|
+
else
|
8
|
+
left_sibling.nil?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_last_of_siblings?(parent = nil)
|
13
|
+
if parent
|
14
|
+
parent.rgt == self.rgt + 1
|
15
|
+
else
|
16
|
+
right_sibling.nil?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def move_lower
|
21
|
+
move_to_right_of(right_sibling) unless is_last_of_siblings?
|
22
|
+
end
|
23
|
+
|
24
|
+
def move_higher
|
25
|
+
move_to_left_of left_sibling unless is_first_of_siblings?
|
26
|
+
end
|
27
|
+
|
28
|
+
def move_to_bottom
|
29
|
+
move_to_right_of siblings.last unless is_last_of_siblings?
|
30
|
+
end
|
31
|
+
|
32
|
+
def move_to_top
|
33
|
+
move_to_left_of siblings.first unless is_first_of_siblings?
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: extended_nested_set
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Patrik Jíra
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: awesome_nested_set
|
16
|
+
requirement: &17554760 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *17554760
|
25
|
+
description: ''
|
26
|
+
email: patrikjira@gmail.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files: []
|
30
|
+
files:
|
31
|
+
- lib/extended_nested_set.rb
|
32
|
+
- lib/extended_nested_set/instance_methods.rb
|
33
|
+
- MIT-LICENSE
|
34
|
+
- Rakefile
|
35
|
+
- README.textile
|
36
|
+
homepage: http://github.com/papricek/extended_nested_set
|
37
|
+
licenses: []
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.5
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Extended nested set
|
60
|
+
test_files: []
|