Module: When::CalendarTypes::Lunar

Included in:
EphemerisBasedLunar, EphemerisBasedLuniSolar, Jewish, PatternTableBasedLuniSolar, ThaiP, ThaiT
Defined in:
lib/when_exe/calendartypes.rb

Overview

太陰(太陽)暦の朔閏パターンを扱うモジュール

Instance Method Summary collapse

Instance Method Details

#lunar_table(year_range, length = 30, duration = When::P1M) ⇒ Hash

朔閏表を生成する

Parameters:

  • year_range (Range)

    生成範囲(西暦年)

  • length (Integer) (defaults to: 30)

    大の月の日数

  • duration (When::TM::Duration) (defaults to: When::P1M)

    チェックする月の間隔

Returns:

  • (Hash)

    朔閏表



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/when_exe/calendartypes.rb', line 147

def lunar_table(year_range, length=30, duration=When::P1M)
  date  = When.TemporalPosition(year_range.first, {:frame=>self}).floor
  table = []
  hash  = {
    'origin_of_MSC' => year_range.first,
    'origin_of_LSC' => date.to_i,
    'rule_table'    => table
  }
  list  = ''
  while year_range.include?(date[When::YEAR])
    month = date[When::MONTH] * 1
    char  = Pattern[month..month]
    char  = char.downcase unless date.length(When::MONTH) == length
    list += char
    succ  = date + duration
    unless date[When::YEAR] == succ[When::YEAR]
      table << list
      list = ''
    end
    date = succ
  end
  hash
end

#verify(base, year_range = base.year_range, length = 30, duration = When::P1M) ⇒ Hash

朔閏表を比較する

Parameters:

  • base (When::TM::Calendar)

    基準とする暦法

  • year_range (Range) (defaults to: base.year_range)

    比較範囲(西暦年)

  • length (Integer) (defaults to: 30)

    大の月の日数

  • duration (When::TM::Duration) (defaults to: When::P1M)

    チェックする月の間隔

Returns:

  • (Hash)

    朔閏表の差分



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/when_exe/calendartypes.rb', line 180

def verify(base, year_range=base.year_range, length=30, duration=When::P1M)
  year_range = When::Parts::GeometricComplex.new(year_range) & When::Parts::GeometricComplex.new(self.year_range) if respond_to?(:year_range)
  base_table = base.lunar_table(year_range, length, duration)
  self_table = self.lunar_table(year_range, length, duration)
  hash = {}
  year_range.each do |year|
    difference = _verify(base_table['rule_table'][year-year_range.first],
                         self_table['rule_table'][year-year_range.first])
    hash[year] = difference if difference
  end
  hash
end