Class: Zakuro::Japan::Type::Base::GengouSet
- Inherits:
-
Object
- Object
- Zakuro::Japan::Type::Base::GengouSet
- Defined in:
- lib/zakuro/era/japan/type/base/gengou_set.rb
Overview
GengouSet 元号セット
Constant Summary collapse
- INVALID =
Returns 不正値.
-1 # @return [Integer] 元号セットID
Instance Attribute Summary collapse
-
#id ⇒ Integer
readonly
元号セットID.
-
#last_date ⇒ Both::Date
readonly
元号セットでの終了日.
-
#last_year ⇒ Both::Year
readonly
元号セットでの終了年.
-
#list ⇒ Array<Gengou>
readonly
元号リスト.
-
#name ⇒ String
readonly
元号セット名.
Instance Method Summary collapse
-
#include_item(date:) ⇒ Gengou
指定した日付を含む元号を返す.
-
#initialize(id: INVALID, name: '', last_year: Both::Year.new, last_date: Both::Date.new, list: []) ⇒ GengouSet
constructor
初期化.
-
#invalid? ⇒ True, False
元号セットが不正かどうかを確認する.
Constructor Details
#initialize(id: INVALID, name: '', last_year: Both::Year.new, last_date: Both::Date.new, list: []) ⇒ GengouSet
初期化
41 42 43 44 45 46 47 48 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 41 def initialize(id: INVALID, name: '', last_year: Both::Year.new, last_date: Both::Date.new, list: []) @id = id @name = name @last_year = last_year @last_date = last_date @list = list end |
Instance Attribute Details
#id ⇒ Integer (readonly)
Returns 元号セットID.
22 23 24 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 22 def id @id end |
#last_date ⇒ Both::Date (readonly)
Returns 元号セットでの終了日.
28 29 30 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 28 def last_date @last_date end |
#last_year ⇒ Both::Year (readonly)
Returns 元号セットでの終了年.
26 27 28 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 26 def last_year @last_year end |
#list ⇒ Array<Gengou> (readonly)
Returns 元号リスト.
30 31 32 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 30 def list @list end |
#name ⇒ String (readonly)
Returns 元号セット名.
24 25 26 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 24 def name @name end |
Instance Method Details
#include_item(date:) ⇒ Gengou
指定した日付を含む元号を返す
57 58 59 60 61 62 63 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 57 def include_item(date:) list.each do |item| return item if item.include?(date: date) end Gengou.new end |
#invalid? ⇒ True, False
元号セットが不正かどうかを確認する
71 72 73 |
# File 'lib/zakuro/era/japan/type/base/gengou_set.rb', line 71 def invalid? @id == INVALID end |