Class Index [+]

Quicksearch

When::TM::IntervalLength

ISO 11404 の時間間隔に基づいて定義された When::TM::Duration の subclass

see gml schema

Constants

SYSTEM

物理的な時間間隔の定数

 時間の「秒」を Float で表現して丸め誤差が発生しない範囲で、
 もっとも大きな時間間隔(86400s を 2 の因数で割りつくした値)
 を単位 SYSTEM とする
DAY
YEAR
MONTH
WEEK
HOUR
MINUTE
SECOND

Attributes

unit[R]

時間間隔を表現するために使用した測定単位の名称

  type : String (year|month|week|day|hour|minute|second|system)
radix[R]

時間単位となる乗数の基底となる正の整数

  type : Integer
factor[R]

基底のべき乗を行う指数

  type : Integer
value[RW]

時間間隔の長さ / 測定単位

  type : Numeric
unit_quantity[R]

測定単位の大きさ

  type : Numeric
interval_length[RW]

時間間隔の長さ ( value * radix ^ (-factor) * unit)

  type : Numeric

Public Class Methods

difference(ended, begun) click to toggle source

オブジェクトの生成(終点と始点を指定)

  ended   : When::TM::(Temporal)Position
    終点
  begun   : When::TM::(Temporal)Position
    始点

  returns : When::TM::IntervalLength
    日単位の精度 - 終点と始点の分解能のいずれかが“日”またはそれより粗い場合
    システム精度 - 終点と始点の分解能がともに“日”より細かい場合
     # File when/tmobjects.rb, line 791
791:     def self.difference(ended, begun)
792:       precision = [ended.precision, begun.precision].min
793:       return new(ended-begun) if precision > When::Coordinates::DAY
794:       return new(ended.to_i - begun.to_i, unit='day')
795:     end
new(value, unit='system', factor=0, radix=10) click to toggle source

オブジェクトの生成

  value  : Numeric
    時間間隔の長さ / 測定単位(省略不可)
  unit   : String (year|month|week|day|hour|minute|second|system)
    時間間隔を表現するために使用した測定単位の名称(デフォルト : system)
  factor : Integer
    基底のべき乗を行う指数(デフォルト : 0)
  radix  : Integer
    時間単位となる乗数の基底となる正の整数(デフォルト : 10)
     # File when/tmobjects.rb, line 770
770:     def initialize(value, unit='system', factor=0, radix=10)
771:       @value, @factor, @radix = value, factor, radix
772:       @unit_quantity   = Unit[unit.downcase] || Unit[Alias[unit[0..0]]] if unit.kind_of?(String)
773:       @unit_quantity ||= unit.to_f
774:       raise TypeError, "Wrong Unit Type: #{unit}" unless @unit_quantity.kind_of?(Numeric)
775:       @unit = Unit.invert[@unit_quantity] ||
776:               When::Coordinates::Pair._en_number(@unit_quantity).to_s
777:       @interval_length = @value * @radix ** (-@factor) * @unit_quantity
778:     end

Public Instance Methods

*(times) click to toggle source

乗算

  times   : Numeric

  returns : When::TM::IntervalLength
     # File when/tmobjects.rb, line 685
685:     def *(times)
686:       interval = self.dup
687:       interval.value           = times * @value
688:       interval.interval_length = times * @interval_length
689:       return interval
690:     end
-@() click to toggle source

符号反転

  returns : When::TM::IntervalLength
     # File when/tmobjects.rb, line 705
705:     def -@
706:       interval = self.dup
707:       interval.value           = -@value
708:       interval.interval_length = -@interval_length
709:       return interval
710:     end
<=>(other) click to toggle source

比較

  other   : Numeric or When::TM::IntervalLength

  returns : Integer
    other との比較により、負,0,正の値を返す
     # File when/tmobjects.rb, line 730
730:     def <=>(other)
731:       +self <=> +other
732:     end
abs() click to toggle source

絶対値

   returns : When::TM::Duration
     # File when/tmobjects.rb, line 716
716:     def abs
717:       interval = self.dup
718:       interval.value           = @value.abs
719:       interval.interval_length = @interval_length.abs
720:       return interval
721:     end
sign() click to toggle source

符号

  returns : Integer
    0 との比較により、負,0,正の値を返す
     # File when/tmobjects.rb, line 697
697:     def sign
698:      @interval_length <=> 0
699:     end
to_s() click to toggle source

文字列化

  returns : String
     # File when/tmobjects.rb, line 738
738:     def to_s
739:       expression = @value.to_s
740:       unless @factor == 0
741:         case @radix
742:         when 10 ; expression += 'E'
743:         when 60 ; expression += 'X'
744:         else    ; expression += '(%d)' % @radix
745:         end
746:         expression += '%+d' % (-@factor)
747:       end
748:       expression += Alias.invert[@unit] || "*#{When::Coordinates::Pair._en_number(@unit)}S"
749:       return expression
750:     end

Private Instance Methods

method_missing(name, *args, &block) click to toggle source

その他のメソッド

  When::TM::IntervalLength で定義されていないメソッドは
  処理を @interval_length (type:Numeric) に委譲する
     # File when/tmobjects.rb, line 803
803:     def method_missing(name, *args, &block)
804:       @interval_length.send(name.to_sym, *args, &block)
805:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.