Module: XPath::XPathObject

Included in:
XPathBoolean, XPathNodeSet, XPathNumber, XPathString
Defined in:
lib/xml/xpath.rb

Instance Method Summary collapse

Instance Method Details

#**(other) ⇒ Object



593
594
595
# File 'lib/xml/xpath.rb', line 593

def **(other)
  type_error 'NodeSet'
end

#<(other) ⇒ Object



561
562
563
564
565
566
567
# 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) ⇒ Object



577
578
579
580
581
582
583
# 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) ⇒ Object

called from compiled XPath expression



552
553
554
555
556
557
558
559
# 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) ⇒ Object



569
570
571
572
573
574
575
# 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) ⇒ Object



585
586
587
588
589
590
591
# 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) ⇒ Object



601
602
603
# File 'lib/xml/xpath.rb', line 601

def at(pos)
  type_error 'NodeSet'
end

#funcall(name) ⇒ Object

for XPointer

Raises:



605
606
607
# File 'lib/xml/xpath.rb', line 605

def funcall(name)   # for XPointer
  raise XPath::NameError, "undefined function `#{name}' for #{_type}"
end

#predicate(&block) ⇒ Object



597
598
599
# File 'lib/xml/xpath.rb', line 597

def predicate(&block)
  type_error 'NodeSet'
end

#to_boolean(context) ⇒ Object

> to XPath Boolean. shouldn’t override.



543
544
545
# File 'lib/xml/xpath.rb', line 543

def to_boolean(context)  # => to XPath Boolean. shouldn't override.
  context.make_boolean true?
end

#to_fObject

> to Ruby Float



518
519
520
# File 'lib/xml/xpath.rb', line 518

def to_f           # => to Ruby Float
  type_error 'Float'
end

#to_number(context) ⇒ Object

> to XPath Number. shouldn’t override.



539
540
541
# File 'lib/xml/xpath.rb', line 539

def to_number(context)   # => to XPath Number. shouldn't override.
  context.make_number to_f
end

#to_predicateObject

> to Ruby Float, true or false. shouldn’t override.



530
531
532
# File 'lib/xml/xpath.rb', line 530

def to_predicate   # => to Ruby Float, true or false. shouldn't override.
  true?
end

#to_rubyObject

> to Ruby Object



526
527
528
# File 'lib/xml/xpath.rb', line 526

def to_ruby        # => to Ruby Object
  self
end

#to_strObject

> to Ruby String



514
515
516
# File 'lib/xml/xpath.rb', line 514

def to_str         # => to Ruby String
  type_error 'String'
end

#to_string(context) ⇒ Object

> to XPath String. shouldn’t override.



535
536
537
# File 'lib/xml/xpath.rb', line 535

def to_string(context)   # => to XPath String. shouldn't override.
  context.make_string to_str
end

#true?Boolean

> to Ruby Boolean

Returns:

  • (Boolean)


522
523
524
# File 'lib/xml/xpath.rb', line 522

def true?          # => to Ruby Boolean
  type_error 'Boolean'
end