Class: Transmogrifier::ValueNode
- Inherits:
-
Node
- Object
- Node
- Transmogrifier::ValueNode
show all
- Defined in:
- lib/transmogrifier/nodes/value_node.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Node
#append, #clone, #delete, for
Constructor Details
#initialize(value, parent_node = nil) ⇒ ValueNode
Returns a new instance of ValueNode.
7
8
9
10
|
# File 'lib/transmogrifier/nodes/value_node.rb', line 7
def initialize(value, parent_node=nil)
@value = value
@parent_node = parent_node
end
|
Instance Attribute Details
#parent_node ⇒ Object
Returns the value of attribute parent_node.
5
6
7
|
# File 'lib/transmogrifier/nodes/value_node.rb', line 5
def parent_node
@parent_node
end
|
Instance Method Details
#find_all(keys) ⇒ Object
12
13
14
15
|
# File 'lib/transmogrifier/nodes/value_node.rb', line 12
def find_all(keys)
return [self] if keys.empty?
raise "cannot find children of ValueNode satisfying non-empty selector #{keys}"
end
|
#modify(pattern, replacement) ⇒ Object
17
18
19
20
|
# File 'lib/transmogrifier/nodes/value_node.rb', line 17
def modify(pattern, replacement)
raise "Value is not modifiable using pattern matching" unless @value.respond_to?(:gsub)
return @value.gsub!(Regexp.new(pattern), replacement)
end
|
#raw ⇒ Object
22
23
24
|
# File 'lib/transmogrifier/nodes/value_node.rb', line 22
def raw
@value
end
|