Class: XML::XXPath::AttrStep
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #create_on(node, create_new) ⇒ Object
-
#initialize(axis, attr_name, attr_value) ⇒ AttrStep
constructor
A new instance of AttrStep.
- #matches?(node) ⇒ Boolean
Methods inherited from Step
Constructor Details
#initialize(axis, attr_name, attr_value) ⇒ AttrStep
Returns a new instance of AttrStep.
98 99 100 101 |
# File 'lib/xml/xxpath/steps.rb', line 98 def initialize(axis,attr_name,attr_value) super(axis) @attr_name,@attr_value = attr_name,attr_value end |
Class Method Details
.compile(axis, string) ⇒ Object
93 94 95 96 |
# File 'lib/xml/xxpath/steps.rb', line 93 def self.compile axis, string /^(?:\.|self::\*)\[@(.*?)='(.*?)'\]$/ === string or return nil self.new axis,$1,$2 end |
Instance Method Details
#create_on(node, create_new) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/xml/xxpath/steps.rb', line 107 def create_on(node,create_new) if create_new raise XXPathError, "XPath: .[@'#{@attr_name}'='#{@attr_value}']: create_new but context node already exists" end # TODO: raise if node.attributes[@attr_name] already exists? node.attributes[@attr_name]=@attr_value node end |