class RDF::Literal::DayTimeDuration
A DayTimeDuration
literal.
‘dayTimeDuration` is a datatype ·derived· from `duration` by restricting its ·lexical representations· to instances of `dayTimeDurationLexicalRep`. The ·value space· of `dayTimeDuration` is therefore that of `duration` restricted to those whose ·months· property is 0. This results in a duration datatype which is totally ordered.
Constants
- DATATYPE
- GRAMMAR
Public Instance Methods
Returns the result of multiplying the value of self by ‘other`. The result is rounded to the nearest month.
From the XQuery function [op:multiply-dayTimeDuration](www.w3.org/TR/xpath-functions/#func-multiply-dayTimeDuration).
@param [Literal::Numeric, ::Numeric] other @return [DayTimeDuration] @see www.w3.org/TR/xpath-functions/#func-multiply-dayTimeDuration
# File lib/rdf/xsd/duration.rb, line 421 def *(other) return type_error("#{other.inspect} is not a valid Numeric") unless (other.is_a?(::Numeric) || other.is_a?(Literal::Numeric)) self.class.new([0, object.last * other.to_f]) end
Returns the sum of two xs:dayTimeDuration values.
From the XQuery function [op:add-dayTimeDurations](www.w3.org/TR/xpath-functions/#func-add-dayTimeDurations).
@param [DayTimeDuration] other @return [DayTimeDuration] @see www.w3.org/TR/xpath-functions/#func-add-dayTimeDurations
# File lib/rdf/xsd/duration.rb, line 395 def +(other) return type_error("#{other.inspect} is not a valid DayTimeDuration") unless other.is_a?(Literal::DayTimeDuration) && other.valid? self.class.new([0, object.last + other.object.last]) end
Returns the result of subtracting one xs:dayTimeDuration value from another.
From the XQuery function [op:subtract-dayTimeDurationss](www.w3.org/TR/xpath-functions/#func-subtract-dayTimeDurations).
@param [DayTimeDuration] other @return [DayTimeDuration] @see www.w3.org/TR/xpath-functions/#func-subtract-dayTimeDurations
# File lib/rdf/xsd/duration.rb, line 408 def -(other) return type_error("#{other.inspect} is not a valid DayTimeDuration") unless other.is_a?(Literal::DayTimeDuration) && other.valid? self.class.new([0, object.last - other.object.last]) end
Returns the result of dividing the value of self by ‘other`. The result is rounded to the nearest month.
From the XQuery functions [op:divide-yearMonthDuration](www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration) and [op:divide-yearMonthDuration-by-yearMonthDuration](www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration-by-dayTimeDuration).
@param [Literal::Numeric, ::Numeric, DayTimeDuration] other @return [DayTimeDuration, Decimal] @see www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration @see www.w3.org/TR/xpath-functions/#func-divide-dayTimeDuration-by-dayTimeDuration
# File lib/rdf/xsd/duration.rb, line 435 def /(other) case other when DayTimeDuration return type_error("#{other.inspect} is not a valid DayTimeDuration or Numeric") unless other.valid? Decimal.new(object.last / other.object.last.to_f) when Literal::Numeric, ::Numeric self.class.new([0, object.last / other.to_f]) else type_error("#{other.inspect} is not a valid DayTimeDuration or Numeric") end end
Compares this literal to ‘other` for sorting purposes.
From the XQuery function [op:dayTimeDuration-less-than](www.w3.org/TR/xpath-functions/#func-dayTimeDuration-less-than).
@param [DayTimeDuration] other @return [Boolean] ‘true` if less than other for defined datatypes @see www.w3.org/TR/xpath-functions/#func-dayTimeDuration-less-than @see www.w3.org/TR/xpath-functions/#func-dayTimeDuration-greater-than
# File lib/rdf/xsd/duration.rb, line 456 def <=>(other) return type_error("#{other.inspect} is not a valid DayTimeDuration") unless other.is_a?(Literal::DayTimeDuration) && other.valid? @object.last <=> other.object.last end
Converts the dayTimeDuration into rational seconds.
@return [Rational]
# File lib/rdf/xsd/duration.rb, line 465 def to_r Rational(object.last) / (24 * 3600) end