Class: JPath::Parser::Attribute

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

Instance Attribute Summary

Attributes inherited from Step

#name, #predicates

Instance Method Summary collapse

Methods inherited from Step

#+, #<<, #initialize, #to_s, #wildcard?

Constructor Details

This class inherits a constructor from JPath::Parser::Step

Instance Method Details

#axisObject



77
78
79
# File 'lib/jpath/parser/step.rb', line 77

def axis
  "attribute"
end

#boolean?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/jpath/parser/step.rb', line 59

def boolean?
  false
end

#value(item, context, index, size) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/jpath/parser/step.rb', line 63

def value(item, context, index, size)
  value = item[context + name]
  if value.nil?
    return nil
  end
  if value =~ /\A\d+\.\d+\z/
    value.to_f
  elsif value =~ /\A\d+\z/
    value.to_i
  else
    value
  end
end