Class: Zakuro::Parameter::Catalog::Range
- Inherits:
-
Object
- Object
- Zakuro::Parameter::Catalog::Range
- Defined in:
- lib/zakuro/parameter/catalog/range.rb
Overview
Range 範囲(開始日-終了日)
Instance Attribute Summary collapse
-
#last ⇒ Date
readonly
終了日.
-
#start ⇒ Date
readonly
開始日.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash: {}) ⇒ Range
constructor
初期化.
-
#invalid? ⇒ True, False
不正か.
Constructor Details
#initialize(hash: {}) ⇒ Range
初期化
29 30 31 32 |
# File 'lib/zakuro/parameter/catalog/range.rb', line 29 def initialize(hash: {}) @start = hash[:start] @last = hash[:last] end |
Instance Attribute Details
#last ⇒ Date (readonly)
Returns 終了日.
20 21 22 |
# File 'lib/zakuro/parameter/catalog/range.rb', line 20 def last @last end |
#start ⇒ Date (readonly)
Returns 開始日.
18 19 20 |
# File 'lib/zakuro/parameter/catalog/range.rb', line 18 def start @start end |
Class Method Details
.validate(hash:) ⇒ Array<Exception::Case::Preset>
検証する
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/zakuro/parameter/catalog/range.rb', line 44 def validate(hash:) failed = [] return failed unless hash unless hash.is_a?(Hash) failed.push( Exception::Case::Preset.new( hash.class, template: Exception::Case::Pattern::INVALID_RANGE_TYPE ) ) return failed end failed.concat(BasisDate.validate(date: hash[:start])) failed.concat(BasisDate.validate(date: hash[:last])) failed end |
Instance Method Details
#invalid? ⇒ True, False
不正か
71 72 73 74 75 76 77 |
# File 'lib/zakuro/parameter/catalog/range.rb', line 71 def invalid? return true unless @start return true unless @end false end |