ISO 11404 の時間間隔に基づいて定義された When::TM::Duration の subclass
see gml schema
オブジェクトの生成(終点と始点を指定)
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
オブジェクトの生成
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
乗算
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
符号反転
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 : Numeric or When::TM::IntervalLength returns : Integer other との比較により、負,0,正の値を返す
# File when/tmobjects.rb, line 730 730: def <=>(other) 731: +self <=> +other 732: end
絶対値
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
符号
returns : Integer 0 との比較により、負,0,正の値を返す
# File when/tmobjects.rb, line 697 697: def sign 698: @interval_length <=> 0 699: end
文字列化
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
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.