Class: Zakuro::Japan::Type::Validation::Both::Year
- Inherits:
-
Object
- Object
- Zakuro::Japan::Type::Validation::Both::Year
- Defined in:
- lib/zakuro/era/japan/type/validation/both/year.rb
Overview
Year 年
Instance Attribute Summary collapse
-
#japan ⇒ String
readonly
和暦元号年.
-
#western ⇒ String
readonly
西暦年.
Instance Method Summary collapse
-
#initialize(hash:) ⇒ Year
constructor
初期化.
-
#japan? ⇒ True, False
和暦元号年を検証する.
-
#validate ⇒ Array<String>
検証する.
-
#western? ⇒ True, False
和暦元号年を検証する.
Constructor Details
#initialize(hash:) ⇒ Year
初期化
27 28 29 30 |
# File 'lib/zakuro/era/japan/type/validation/both/year.rb', line 27 def initialize(hash:) @japan = hash['japan'] @western = hash['western'] end |
Instance Attribute Details
#japan ⇒ String (readonly)
Returns 和暦元号年.
18 19 20 |
# File 'lib/zakuro/era/japan/type/validation/both/year.rb', line 18 def japan @japan end |
#western ⇒ String (readonly)
Returns 西暦年.
20 21 22 |
# File 'lib/zakuro/era/japan/type/validation/both/year.rb', line 20 def western @western end |
Instance Method Details
#japan? ⇒ True, False
和暦元号年を検証する
53 54 55 56 57 |
# File 'lib/zakuro/era/japan/type/validation/both/year.rb', line 53 def japan? return false unless @japan japan.is_a?(Integer) end |
#validate ⇒ Array<String>
検証する
37 38 39 40 41 42 43 44 45 |
# File 'lib/zakuro/era/japan/type/validation/both/year.rb', line 37 def validate failed = [] failed.push("invalid japan year. #{japan}") unless japan? failed.push("invalid western year. #{western}") unless western? failed end |
#western? ⇒ True, False
和暦元号年を検証する
65 66 67 68 69 |
# File 'lib/zakuro/era/japan/type/validation/both/year.rb', line 65 def western? return false unless @western western.is_a?(Integer) end |