Class: Chawan::Node
Defined Under Namespace
Modules: GatewayInterface
Instance Attribute Summary collapse
Instance Method Summary
collapse
#noun?, #verb?
Constructor Details
#initialize(vals, keys) ⇒ Node
Returns a new instance of Node.
18
19
20
21
|
# File 'lib/chawan/node.rb', line 18
def initialize(vals, keys)
@vals = vals
@keys = keys
end
|
Instance Attribute Details
#keys ⇒ Object
Returns the value of attribute keys.
4
5
6
|
# File 'lib/chawan/node.rb', line 4
def keys
@keys
end
|
#vals ⇒ Object
Returns the value of attribute vals.
3
4
5
|
# File 'lib/chawan/node.rb', line 3
def vals
@vals
end
|
Instance Method Details
#[](index) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/chawan/node.rb', line 27
def [](index)
case index
when Integer
vals[keys[index]]
else
attributes[index.to_s]
end
end
|
#attributes ⇒ Object
23
24
25
|
# File 'lib/chawan/node.rb', line 23
def attributes
@attributes ||= Hash[*keys.zip(vals).flatten]
end
|
#category ⇒ Object
40
41
42
|
# File 'lib/chawan/node.rb', line 40
def category
vals[1]
end
|
#inspect ⇒ Object
48
49
50
|
# File 'lib/chawan/node.rb', line 48
def inspect
"<%s: '%s'>" % [category, to_s]
end
|
#to_s ⇒ Object
44
45
46
|
# File 'lib/chawan/node.rb', line 44
def to_s
word
end
|
#word ⇒ Object
36
37
38
|
# File 'lib/chawan/node.rb', line 36
def word
vals.first.to_s
end
|