Class: Zakuro::Parameter::Condition
- Inherits:
-
Object
- Object
- Zakuro::Parameter::Condition
- Defined in:
- lib/zakuro/parameter/condition.rb
Overview
Condition 条件
Instance Attribute Summary collapse
-
#columns ⇒ Array<String>
readonly
列.
-
#date ⇒ Date
readonly
基準日.
-
#options ⇒ Hash<String, Object>
readonly
オプション.
-
#range ⇒ Hash<Symbol, Date>
readonly
範囲.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash: {}) ⇒ Condition
constructor
初期化.
-
#rewrite(hash: {}) ⇒ Object
上書きする.
Constructor Details
#initialize(hash: {}) ⇒ Condition
初期化
36 37 38 39 40 41 |
# File 'lib/zakuro/parameter/condition.rb', line 36 def initialize(hash: {}) @date = hash[:date] @range = hash[:range] @columns = hash[:columns] = hash[:options] || {} end |
Instance Attribute Details
#columns ⇒ Array<String> (readonly)
Returns 列.
23 24 25 |
# File 'lib/zakuro/parameter/condition.rb', line 23 def columns @columns end |
#date ⇒ Date (readonly)
Returns 基準日.
19 20 21 |
# File 'lib/zakuro/parameter/condition.rb', line 19 def date @date end |
#options ⇒ Hash<String, Object> (readonly)
Returns オプション.
25 26 27 |
# File 'lib/zakuro/parameter/condition.rb', line 25 def end |
#range ⇒ Hash<Symbol, Date> (readonly)
Returns 範囲.
21 22 23 |
# File 'lib/zakuro/parameter/condition.rb', line 21 def range @range end |
Class Method Details
.validate(hash:) ⇒ Array<Exception::Case::Preset>
検証する
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/zakuro/parameter/condition.rb', line 69 def validate(hash:) failed = [] unless hash.is_a?(Hash) failed.push( Exception::Case::Preset.new( hash.class, template: Exception::Case::Pattern::INVALID_CONDITION_TYPE ) ) return failed end failed.concat(validate_hash(hash: hash)) failed end |
Instance Method Details
#rewrite(hash: {}) ⇒ Object
上書きする
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/zakuro/parameter/condition.rb', line 48 def rewrite(hash: {}) instance_variables.each do |var| key = var.to_s.delete('@') val = hash[key.intern] next unless val instance_variable_set(var, val) end end |