暦座標値
暦座標の値を表現する
@trunk, @branch を取得する
others : Integer(1,0,-1) returns : Numeric other == 1 - @trunk other == 0 - @branch other == -1 - -@trunk When::Coordinates::Pair 以外の Numeric では、1 による乗算は恒等変換になる。 また、0 による乗算は恒に 0になる。 このため、When::TM::Calendar や When::TM::Clock の実装は、暦要素が When::Coordinates::Pair か 否かを判断することなく、暦要素に 1 による乗算を施すことによって、trunk に相当する値を、 0 による乗算を施すことによって、branch に相当する値を取得できる。
# File when/coordinates.rb, line 762 762: def *(other) 763: case other 764: when 1 ; @trunk 765: when 0 ; @branch 766: when 1 ; -@trunk 767: else ; raise ArgumentError, "Irregal designation : #{other}" 768: end 769: end
加算
other : Numeric returns : When::Coordinates::Pair other が When::Coordinates::Pair でない場合、trunk に対する加算となる
# File when/coordinates.rb, line 778 778: def +(other) 779: return self.class.new((@trunk||0) + other, @branch) unless other.kind_of?(self.class) 780: return self.class.new((@trunk||0) + (other.trunk||0), (@branch||0) + (other.branch||0)) 781: end
@sum を取得する
returns : Numeric @sum When::Coordinates::Pair 以外の Numeric では、単項演算 + は恒等変換になる。 このため、When::TM::Calendar や When::TM::Clock の実装は、暦要素が When::Coordinates::Pair か 否かを判断することなく、暦要素に単項演算 + を施すことによって、必要な暦要素を取得できる。
# File when/coordinates.rb, line 735 735: def +@ 736: return @sum 737: end
減算
other : Numeric returns : When::Coordinates::Pair other が When::Coordinates::Pair でない場合、trunk に対する減算となる
# File when/coordinates.rb, line 790 790: def -(other) 791: return self.class.new((@trunk||0) - other, @branch) unless other.kind_of?(self.class) 792: return self.class.new((@trunk||0) - (other.trunk||0), (@branch||0) - (other.branch||0)) 793: end
trunk の符号を反転する
returns : Numeric Pair.new(-@trunk, @branch)
# File when/coordinates.rb, line 744 744: def -@ 745: return self.class.new(-(@trunk||0), @branch) 746: end
比較
other : Numeric returns : Integer(負,0,正) trunk の比較が優先される
# File when/coordinates.rb, line 814 814: def <=>(other) 815: other = self.class._force_pair(other) 816: (@trunk <=> other.trunk).nonzero? || ((@branch||0) <=> (other.branch||0)) 817: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.