Class: JPath::Parser::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/jpath/parser/step.rb

Direct Known Subclasses

Attribute, Node, Root, Self

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Step

Returns a new instance of Step.



9
10
11
12
# File 'lib/jpath/parser/step.rb', line 9

def initialize(name)
  @name = name
  @predicates = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/jpath/parser/step.rb', line 5

def name
  @name
end

#predicatesObject (readonly)

Returns the value of attribute predicates.



7
8
9
# File 'lib/jpath/parser/step.rb', line 7

def predicates
  @predicates
end

Instance Method Details

#+(other) ⇒ Object



18
19
20
# File 'lib/jpath/parser/step.rb', line 18

def +(other)
  other.add(self)
end

#<<(predicate) ⇒ Object



22
23
24
# File 'lib/jpath/parser/step.rb', line 22

def <<(predicate)
  @predicates << predicate
end

#to_sObject



26
27
28
# File 'lib/jpath/parser/step.rb', line 26

def to_s
  "%s::%s%s" % [axis, name, predicates.map(&:to_s).join("")]
end

#wildcard?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/jpath/parser/step.rb', line 14

def wildcard?
  name == '*'
end