lib/rdf/xsd/duration.rb
##
# Converts this literal into its canonical lexical representation.
#
# Also normalizes elements
#
# @return [RDF::Literal] `self`
# @see    https://www.w3.org/TR/xmlschema11-2/#dateTime
Converts this literal into its canonical lexical representation.
Also normalizes elements
Converts this literal into its canonical lexical representation . Also normalizes elements
def canonicalize!
      @string = @humanize = nil
      if @object[:se].to_i > 60
        m_r = (@object[:se].to_f / 60) - 1
        @object[:se] -=  m_r * 60
        @object[:mi] = @object[:mi].to_i + m_r
      end
      if @object[:mi].to_i > 60
        h_r = (@object[:mi].to_i / 60) - 1
        @object[:mi] -=  h_r * 60
        @object[:hr] = @object[:hr].to_i +  h_r
      end
      if @object[:hr].to_i > 24
        d_r = (@object[:hr].to_i / 24) - 1
        @object[:hr] -=  d_r * 24
        @object[:da] = @object[:da].to_i + d_r
      end
      if @object[:da].to_i > 30
        m_r = (@object[:da].to_i / 30) - 1
        @object[:da] -=  m_r * 30
        @object[:mo] = @object[:mo].to_i + m_r
      end
      if @object[:mo].to_i > 12
        y_r = (@object[:mo].to_i / 12) - 1
        @object[:mo] -=  y_r * 12
        @object[:yr] = @object[:yr].to_i + y_r
      end
      @object.to_s  
      self
    end
def canonicalize! @string = @humanize = nil if @object [ :se ] . to_i > 60 m_r = ( @object [ :se ] . to_f / 60 ) - 1 @object [ :se ] -= m_r * 60 @object [ :mi ] = @object [ :mi ] . to_i + m_r end if @object [ :mi ] . to_i > 60 h_r = ( @object [ :mi ] . to_i / 60 ) - 1 @object [ :mi ] -= h_r * 60 @object [ :hr ] = @object [ :hr ] . to_i + h_r end if @object [ :hr ] . to_i > 24 d_r = ( @object [ :hr ] . to_i / 24 ) - 1 @object [ :hr ] -= d_r * 24 @object [ :da ] = @object [ :da ] . to_i + d_r end if @object [ :da ] . to_i > 30 m_r = ( @object [ :da ] . to_i / 30 ) - 1 @object [ :da ] -= m_r * 30 @object [ :mo ] = @object [ :mo ] . to_i + m_r end if @object [ :mo ] . to_i > 12 y_r = ( @object [ :mo ] . to_i / 12 ) - 1 @object [ :mo ] -= y_r * 12 @object [ :yr ] = @object [ :yr ] . to_i + y_r end @object . to_s self end
Converts this literal into its canonical lexical representation.
Converts this literal into its canonical lexical representation .
# side-effect
None
RDF::Literal
see
None