module XPath::XPathObject

Public Instance Methods

**(other) click to toggle source
# File lib/xml/xpath.rb, line 593
def **(other)
  type_error 'NodeSet'
end
<(other) click to toggle source
# File lib/xml/xpath.rb, line 561
def <(other)
  if other.is_a? XPathNodeSet then
    other > self
  else
    to_f < other.to_f
  end
end
<=(other) click to toggle source
# File lib/xml/xpath.rb, line 577
def <=(other)
  if other.is_a? XPathNodeSet then
    other >= self
  else
    to_f <= other.to_f
  end
end
==(other) click to toggle source

called from compiled XPath expression

# File lib/xml/xpath.rb, line 552
def ==(other)
  if other.is_a? XPathNodeSet or
      other.is_a? XPathBoolean or other.is_a? XPathNumber then
    other == self
  else
    to_str == other.to_str
  end
end
>(other) click to toggle source
# File lib/xml/xpath.rb, line 569
def >(other)
  if other.is_a? XPathNodeSet then
    other < self
  else
    to_f > other.to_f
  end
end
>=(other) click to toggle source
# File lib/xml/xpath.rb, line 585
def >=(other)
  if other.is_a? XPathNodeSet then
    other <= self
  else
    to_f >= other.to_f
  end
end
at(pos) click to toggle source
# File lib/xml/xpath.rb, line 601
def at(pos)
  type_error 'NodeSet'
end
funcall(name) click to toggle source
# File lib/xml/xpath.rb, line 605
def funcall(name)   # for XPointer
  raise XPath::NameError, "undefined function `#{name}' for #{_type}"
end
predicate(&block) click to toggle source
# File lib/xml/xpath.rb, line 597
def predicate(&block)
  type_error 'NodeSet'
end
to_boolean(context) click to toggle source
# File lib/xml/xpath.rb, line 543
def to_boolean(context)  # => to XPath Boolean. shouldn't override.
  context.make_boolean true?
end
to_f() click to toggle source
# File lib/xml/xpath.rb, line 518
def to_f           # => to Ruby Float
  type_error 'Float'
end
to_number(context) click to toggle source
# File lib/xml/xpath.rb, line 539
def to_number(context)   # => to XPath Number. shouldn't override.
  context.make_number to_f
end
to_predicate() click to toggle source
# File lib/xml/xpath.rb, line 530
def to_predicate   # => to Ruby Float, true or false. shouldn't override.
  true?
end
to_ruby() click to toggle source
# File lib/xml/xpath.rb, line 526
def to_ruby        # => to Ruby Object
  self
end
to_str() click to toggle source
# File lib/xml/xpath.rb, line 514
def to_str         # => to Ruby String
  type_error 'String'
end
to_string(context) click to toggle source
# File lib/xml/xpath.rb, line 535
def to_string(context)   # => to XPath String. shouldn't override.
  context.make_string to_str
end
true?() click to toggle source
# File lib/xml/xpath.rb, line 522
def true?          # => to Ruby Boolean
  type_error 'Boolean'
end

Private Instance Methods

_type() click to toggle source
# File lib/xml/xpath.rb, line 503
def _type
  type.name.sub(/\A.*::(?:XPath)?(?=[^:]+\z)/, '')
end
type_error(into) click to toggle source
# File lib/xml/xpath.rb, line 508
def type_error(into)
  raise XPath::TypeError, "failed to convert #{_type} into #{into}"
end