Class Index [+]

Quicksearch

When::CalendarTypes::TableBased

月日の配当パターンの種類が限定されている暦の抽象基底クラス

  Calendar which has some fixed arrangement rules for under year

  新年の日付が専用メソッドで与えられ、月日の配当が1年の日数等
  で決まる暦。いわゆる Rule-Based な暦はほとんど該当します。

Public Instance Methods

_coordinates_to_number(y, m, d) click to toggle source

年月日 -> 通日

  y       - 年
  m       - 月 (0 始まり)
  d       - 日 (0 始まり)

  returns : 通日
     # File when/calendartypes.rb, line 138
138:     def _coordinates_to_number(y, m, d)
139:       sdn  = _sdn([+y])
140:       rule = _rule(_key([+y]))
141:       sdn += d + rule['Offset'][m]
142:       return sdn if d >= 0
143:       return sdn + rule['Length'][m % rule['Length'].length]
144:     end
_ids_(date) click to toggle source

日時要素の翻訳表の取得

  date    : [y]
    y - 年

  returns : [When::Coordinates::Pair]
    日時要素の翻訳表
     # File when/calendartypes.rb, line 257
257:     def _ids_(date)
258:       _rule(_key(date))['IDs']
259:     end
_key_(date) click to toggle source

暦日表のキー取得

  date    : [y]
    y - 年

  returns : 暦日表のキー
    本暦法では当該年の日数を暦日表のキーとします
     # File when/calendartypes.rb, line 243
243:     def _key_(date)
244:       n_date = date.dup
245:       n_date[1] += 1
246:      _sdn(n_date) - _sdn(date)
247:     end
_length(date) click to toggle source

暦要素数

  引数パターン1
    date    : [y]
      y     - 年
    returns : その年の月数

  引数パターン2
    date    : [y, m]
      y     - 年
      m     - 月 (0 始まり)
    returns : その年月の日数
     # File when/calendartypes.rb, line 180
180:     def _length(date)
181:       y, m = date
182:       if (m)
183:         #  指定した月に含まれる日の数を返します。
184:         return @unit[2] if @unit[2]
185:         rule = _rule(_key([y]))
186:         return rule['Length'][m % rule['Length'].length]
187:       else
188:         #  指定した年に含まれる月の数を返します。
189:         return @unit[1] if @unit[1]
190:         return _rule(_key([y]))['Months']
191:       end
192:     end
_number_to_coordinates(sdn) click to toggle source

通日 - > 年月日

  sdn     : 通日

  returns : [y, m, d]
    y     - 年
    m     - 月 (0 始まり)
    d     - 日 (0 始まり)
     # File when/calendartypes.rb, line 155
155:     def _number_to_coordinates(sdn)
156:       y, d = Residue.mod(sdn) {|n| _sdn([n])}
157:       rule = _rule(_key([y]))
158:       (rule['Months']-1).downto(0) do |m|
159:         if d >=rule['Offset'][m]
160:           d -= rule['Offset'][m]
161:           return [y, m, d]
162:         end
163:       end
164:       return nil
165:     end
_sdn_(date) click to toggle source

年初の通日

  このメソッドは subclass で定義します

  date    : [y]
    y - 年

  returns : 年初の通日
     # File when/calendartypes.rb, line 231
231:     def _sdn_(date)
232:       raise TypeError, "Abstract TableBased Calendar Type"
233:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.