Class: When::CalendarTypes::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

初期設定


454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/when_exe/region/japanese_notes.rb', line 454

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
        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::Julian) ? @l_date : @o_date
  @s_date    = @cal4note.s_calendar ^ date
end

Instance Attribute Details

#cal4noteObject (readonly)

Returns the value of attribute cal4note


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def cal4note
  @cal4note
end

#index_gObject (readonly)

Returns the value of attribute index_g


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def index_g
  @index_g
end

#index_sObject (readonly)

Returns the value of attribute index_s


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def index_s
  @index_s
end

#l_dateObject (readonly)

Returns the value of attribute l_date


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def l_date
  @l_date
end

#m_dateObject (readonly)

Returns the value of attribute m_date


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def m_date
  @m_date
end

#o_dateObject (readonly)

Returns the value of attribute o_date


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def o_date
  @o_date
end

#precisionObject (readonly)

Returns the value of attribute precision


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def precision
  @precision
end

#rangeObject (readonly)

Returns the value of attribute range


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def range
  @range
end

#s_dateObject (readonly)

Returns the value of attribute s_date


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def s_date
  @s_date
end

#yearObject (readonly)

Returns the value of attribute year


451
452
453
# File 'lib/when_exe/region/japanese_notes.rb', line 451

def year
  @year
end