Class: XML::XXPath::AlternativeNamesStep

Inherits:
Step
  • Object
show all
Defined in:
lib/xml/xxpath/steps.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Step

#creator, inherited, #reader

Constructor Details

#initialize(axis, names) ⇒ AlternativeNamesStep

Returns a new instance of AlternativeNamesStep.



287
288
289
290
# File 'lib/xml/xxpath/steps.rb', line 287

def initialize(axis,names)
  super(axis)
  @names = names
end

Class Method Details

.compile(axis, string) ⇒ Object



279
280
281
282
283
284
285
# File 'lib/xml/xxpath/steps.rb', line 279

def self.compile axis, string
  if string=~/\|/
    self.new axis, string.split('|')
  else
    nil
  end
end

Instance Method Details

#create_on(node, create_new) ⇒ Object



296
297
298
299
300
# File 'lib/xml/xxpath/steps.rb', line 296

def create_on(node,create_new)
  newnode = node.elements.add
  newnode.unspecified = true
  newnode
end

#matches?(node) ⇒ Boolean

Returns:

  • (Boolean)


292
293
294
# File 'lib/xml/xxpath/steps.rb', line 292

def matches? node
  node.is_a?(REXML::Element) and @names.inject(false){|prev,name| prev or node.name==name}
end