class XPath::XPathNumber
Public Class Methods
Source
# File lib/xml/xpath.rb, line 685 def initialize(num) raise ::TypeError, "must be a Float" unless num.is_a? Float @value = num end
Public Instance Methods
Source
# File lib/xml/xpath.rb, line 753 def %(other) n = other.to_f f = @value % n f = -f if @value < 0 f = -f if n < 0 @value = f self end
Source
# File lib/xml/xpath.rb, line 725 def ==(other) if other.is_a? XPathNodeSet or other.is_a? XPathBoolean then other == self else @value == other.to_f end end
Source
# File lib/xml/xpath.rb, line 777 def round f = @value unless f.nan? or f.infinite? then if f >= 0.0 then @value = f.round.to_f elsif f - f.truncate >= -0.5 then @value = f.ceil.to_f else @value = f.floor.to_f end end self end
Source
# File lib/xml/xpath.rb, line 690 def to_str if @value.nan? then 'NaN' elsif @value.infinite? then if @value < 0 then '-Infinity' else 'Infinity' end else sprintf("%.100f", @value).gsub(/\.?0+\z/, '') # enough? end end