Class: Command::Results::ListItem
- Inherits:
-
Object
- Object
- Command::Results::ListItem
show all
- Defined in:
- lib/command-set/result-list.rb
Overview
The root class of the List class family. A compositable tree, iterated by ListIterator.
Defined Under Namespace
Classes: Exception, NoMatch
Constant Summary
collapse
- @@next_seq =
0
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value) ⇒ ListItem
Returns a new instance of ListItem.
10
11
12
13
14
15
16
17
|
# File 'lib/command-set/result-list.rb', line 10
def initialize(value)
@sequence = (@@next_seq +=1)
@value = value
@order = nil
@parent = nil
@options = {}
@depth = 0
end
|
Instance Attribute Details
#depth ⇒ Object
Returns the value of attribute depth.
20
21
22
|
# File 'lib/command-set/result-list.rb', line 20
def depth
@depth
end
|
#options ⇒ Object
Returns the value of attribute options.
20
21
22
|
# File 'lib/command-set/result-list.rb', line 20
def options
@options
end
|
#order ⇒ Object
Returns the value of attribute order.
20
21
22
|
# File 'lib/command-set/result-list.rb', line 20
def order
@order
end
|
#parent ⇒ Object
Returns the value of attribute parent.
20
21
22
|
# File 'lib/command-set/result-list.rb', line 20
def parent
@parent
end
|
#sequence ⇒ Object
Returns the value of attribute sequence.
19
20
21
|
# File 'lib/command-set/result-list.rb', line 19
def sequence
@sequence
end
|
#value ⇒ Object
Returns the value of attribute value.
19
20
21
|
# File 'lib/command-set/result-list.rb', line 19
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Object
22
23
24
25
|
# File 'lib/command-set/result-list.rb', line 22
def ==(other)
return (ListItem === other &&
value == other.value)
end
|
#eql?(other) ⇒ Boolean
44
45
46
|
# File 'lib/command-set/result-list.rb', line 44
def eql?(other)
return self == other
end
|
#filter(path) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/command-set/result-list.rb', line 67
def filter(path)
if path.empty? || path == [:**]
return self
else
raise NoMatch
end
end
|
#inspect ⇒ Object
75
76
77
|
# File 'lib/command-set/result-list.rb', line 75
def inspect
"<i(#{@order}) #{value.inspect}>"
end
|
#match(key) ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/command-set/result-list.rb', line 57
def match(key)
if key == :*
return true
elsif key == :**
return true
else
match_on(key)
end
end
|
#match_on(value) ⇒ Object
53
54
55
|
# File 'lib/command-set/result-list.rb', line 53
def match_on(value)
return value.to_s == self.to_s
end
|
#next_sibling ⇒ Object
48
49
50
51
|
# File 'lib/command-set/result-list.rb', line 48
def next_sibling
return nil if self.parent.nil?
return self.parent.after(self)
end
|
#to_s ⇒ Object
40
41
42
|
# File 'lib/command-set/result-list.rb', line 40
def to_s
return @value.to_s
end
|
#tree_order_next ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/command-set/result-list.rb', line 27
def tree_order_next
right = self.next_sibling
if right.nil?
if self.parent.nil?
return nil
else
return self.parent.list_end
end
else
return right
end
end
|