Parent

Class Index [+]

Quicksearch

When::Coordinates::Pair

暦座標値

  暦座標の値を表現する

Attributes

trunk[RW]

暦要素の幹

  type : Numeric
    年番号,月番号,日番号など暦要素の幹となる部分
branch[RW]

暦要素の枝

  type : Numeric
    (閏であるかなど)暦要素のうち幹で表現しきれない枝の部分
sum[R]

暦要素の幹と枝の和

  type : Numeric
    個別の実装において、本変数が When::TM::Calendar や When::TM::Clock が扱うべき
    座標値を表すように配慮されている。

  例: 会計年度など年の変わり目が暦年と異なる場合、trunk+=1, branch-=1 として、
      trunk が会計年度, sum が暦年を表現するようにできる。この場合、trunk は表記上の
      年、branch は会計年度と暦年にずれがあるという情報を表現していることになる。

Public Class Methods

new(trunk, branch=nil) click to toggle source

オブジェクトの生成

    trunk  : Numeric
      幹
    branch : Numeric
      枝
     # File when/coordinates.rb, line 845
845:     def initialize(trunk, branch=nil)
846:       @trunk  = trunk
847:       @branch = branch
848:       _normalize
849:     end

Public Instance Methods

*(other) click to toggle source

@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) click to toggle source

加算

  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
+@() click to toggle source

@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) click to toggle source

減算

  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
-@() click to toggle source

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) click to toggle source

比較

  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
divmod(other) click to toggle source

商と剰余

  other   : Numeric

  returns : When::Coordinates::Pair
    trunk に対する divmod となる
     # File when/coordinates.rb, line 802
802:     def divmod(other)
803:       div, mod = (@trunk||0).divmod(other)
804:       return div, self.class.new(mod, @branch)
805:     end
to_s(zero='') click to toggle source

文字列化

  zero : String

  returns : String
     # File when/coordinates.rb, line 825
825:     def to_s(zero='')
826:       return @trunk.to_s + (((@branch||0)==0) ? zero : DL2[@branch])
827:     end

Private Instance Methods

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

その他のメソッド

  When::Coordinates:Pair で定義されていないメソッドは
  処理を @sum (type:Numeric) に委譲する
     # File when/coordinates.rb, line 866
866:     def method_missing(name, *args, &block)
867:       @sum.send(name.to_sym, *args, &block)
868:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.