module ISO8601::Atomic
Attributes
atom[R]
Public Instance Methods
<=>(other)
click to toggle source
@param [Atom] other The contrast to compare against
@return [-1, 0, 1]
# File lib/iso8601/atomic.rb, line 46 def <=>(other) return nil unless other.is_a?(self.class) to_f <=> other.to_f end
eql?(other)
click to toggle source
@param [#hash] other The contrast to compare against
@return [Boolean]
# File lib/iso8601/atomic.rb, line 56 def eql?(other) (hash == other.hash) end
hash()
click to toggle source
@return [Fixnum]
# File lib/iso8601/atomic.rb, line 62 def hash [atom, self.class].hash end
to_f()
click to toggle source
The float representation
@return [Float]
# File lib/iso8601/atomic.rb, line 21 def to_f atom.to_f end
to_i()
click to toggle source
The integer representation
@return [Integer]
# File lib/iso8601/atomic.rb, line 13 def to_i atom.to_i end
to_s()
click to toggle source
Returns the ISO 8601 representation for the atom
@return [String]
# File lib/iso8601/atomic.rb, line 29 def to_s value.zero? ? '' : "#{value}#{symbol}" end
valid_atom?(atom)
click to toggle source
Validates the atom is a Numeric
# File lib/iso8601/atomic.rb, line 68 def valid_atom?(atom) raise(ISO8601::Errors::TypeError, "The atom argument for #{self.class} should be a Numeric value.") \ unless atom.is_a?(Numeric) end
valid_base?(base)
click to toggle source
# File lib/iso8601/atomic.rb, line 73 def valid_base?(base) raise(ISO8601::Errors::TypeError, "The base argument for #{self.class} should be a ISO8601::DateTime instance or nil.") \ unless base.is_a?(ISO8601::DateTime) || base.nil? end
value()
click to toggle source
The simplest numeric representation. If modulo equals 0 returns an integer else a float.
@return [Numeric]
# File lib/iso8601/atomic.rb, line 38 def value (atom % 1).zero? ? atom.to_i : atom end