Class: XML::XXPath::NameAndAttrStep
- Defined in:
- lib/xml/xxpath/steps.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #create_on(node, create_new) ⇒ Object
-
#initialize(axis, name, attr_name, attr_value) ⇒ NameAndAttrStep
constructor
A new instance of NameAndAttrStep.
- #matches?(node) ⇒ Boolean
Methods inherited from Step
Constructor Details
#initialize(axis, name, attr_name, attr_value) ⇒ NameAndAttrStep
Returns a new instance of NameAndAttrStep.
124 125 126 127 |
# File 'lib/xml/xxpath/steps.rb', line 124 def initialize(axis,name,attr_name,attr_value) super(axis) @name,@attr_name,@attr_value = name,attr_name,attr_value end |
Class Method Details
.compile(axis, string) ⇒ Object
119 120 121 122 |
# File 'lib/xml/xxpath/steps.rb', line 119 def self.compile axis, string /^(.*?)\[@(.*?)='(.*?)'\]$/ === string or return nil self.new axis,$1,$2,$3 end |
Instance Method Details
#create_on(node, create_new) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/xml/xxpath/steps.rb', line 133 def create_on(node,create_new) if create_new newnode = node.elements.add(@name) else newnode = node.elements.select{|elt| elt.name==@name and not(elt.attributes[@attr_name])}[0] if not(newnode) newnode = node.elements.add(@name) end end newnode.attributes[@attr_name]=@attr_value newnode end |