Class: Zakuro::Calculation::Gengou::Reserve::DatedList
- Inherits:
-
AbstractList
- Object
- AbstractList
- Zakuro::Calculation::Gengou::Reserve::DatedList
- Defined in:
- lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb
Overview
List
予約元号一覧
Constant Summary
Constants inherited from AbstractList
AbstractList::INVALID_YEAR, AbstractList::MAX_MONTH_DAYS
Instance Attribute Summary
Attributes inherited from AbstractList
#index, #last_date, #list, #operated, #restored, #start_date
Instance Method Summary collapse
-
#initialize(first: true, start_date: Western::Calendar.new, last_date: Western::Calendar, operated: false, restored: false) ⇒ DatedList
constructor
初期化.
-
#update ⇒ Object
予約元号一覧を更新する.
Methods inherited from AbstractList
#change_start_date?, #collect, #get, #invalid?, #japan_start_date, #native_start_date, #western_last_date, #western_last_year, #western_start_date, #western_start_year
Constructor Details
#initialize(first: true, start_date: Western::Calendar.new, last_date: Western::Calendar, operated: false, restored: false) ⇒ DatedList
初期化
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb', line 27 def initialize(first: true, start_date: Western::Calendar.new, last_date: Western::Calendar, operated: false, restored: false) @index = parse_index(first: first) @start_date = start_date.clone @last_date = last_date.invalid? ? start_date.clone : last_date.clone super( index: @index, start_date: start_date, last_date: last_date, operated: operated, restored: restored ) end |
Instance Method Details
#update ⇒ Object
予約元号一覧を更新する
41 42 43 44 45 46 47 48 |
# File 'lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb', line 41 def update # 開始日の30日前に前の元号がある場合は、前の元号を設定する start = start_date.clone - (MAX_MONTH_DAYS + 1) # 開始日の30日後に次の元号がある場合は、次の元号を設定する last = last_date.clone + (MAX_MONTH_DAYS + 1) @list |= line(start_date: start, last_date: last) end |