Class: When::CalendarNote::JapaneseNote::Dates

Inherits:
Object
  • Object
show all
Defined in:
lib/when_exe/region/japanese_notes.rb

Overview

日本暦注計算に必要となる暦日や暦法をまとめた内部クラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, year = date.most_significant_coordinate, precision = date.precision, cal4note = nil) ⇒ Dates

初期設定



401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/when_exe/region/japanese_notes.rb', line 401

def initialize(date, year=date.most_significant_coordinate, precision=date.precision, cal4note=nil)

  # 暦注パターン
  if cal4note
    # 年代による判定
    (1...NoteRange.size).to_a.reverse.each do |i|
      if year >= NoteRange[i][0]
        @range = i
        break
      end
    end
    @range ||= 0
  else
    # 暦法による判定
    cal4note = Cal4Note.new(date.frame, date.frame.twin)
    @range =
      case cal4note.l_calendar.formula[-1]
      when When::Ephemeris::ChineseTrueLunation::JujiMethods ; 11 # 江戸時代の暦
      when When::Ephemeris::ChineseTrueLunation
        date.frame.twin =~ /戊寅|麟徳/ ? 1 : 10 # 唐代定朔暦(儀鳳暦 or 宣明暦)
      when When::Ephemeris::MeanLunation   ;  0 # 唐代以前平朔暦(元嘉暦)
      else                                 ; 15 # 現代の旧暦
      end
  end

  # 具注暦の配置
  @index_g = NoteRange[@range][1]

  # 七十二候
  @index_s = NoteRange[@range][2]

  # その他の属性
  @year      = year
  @precision = precision
  @cal4note  = cal4note
  @o_date    = date
  @l_date    = @cal4note.l_calendar ^ date
  @m_date    = date.frame.kind_of?(When::CalendarTypes::Christian) ? @l_date : @o_date
  @s_date    = @cal4note.s_calendar ^ date
end

Instance Attribute Details

#cal4noteObject (readonly)

Returns the value of attribute cal4note.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def cal4note
  @cal4note
end

#index_gObject (readonly)

Returns the value of attribute index_g.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def index_g
  @index_g
end

#index_sObject (readonly)

Returns the value of attribute index_s.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def index_s
  @index_s
end

#l_dateObject (readonly)

Returns the value of attribute l_date.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def l_date
  @l_date
end

#m_dateObject (readonly)

Returns the value of attribute m_date.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def m_date
  @m_date
end

#o_dateObject (readonly)

Returns the value of attribute o_date.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def o_date
  @o_date
end

#precisionObject (readonly)

Returns the value of attribute precision.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def precision
  @precision
end

#rangeObject (readonly)

Returns the value of attribute range.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def range
  @range
end

#s_dateObject (readonly)

Returns the value of attribute s_date.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def s_date
  @s_date
end

#yearObject (readonly)

Returns the value of attribute year.



398
399
400
# File 'lib/when_exe/region/japanese_notes.rb', line 398

def year
  @year
end