Class: Zakuro::Merchant
- Inherits:
-
Object
- Object
- Zakuro::Merchant
- Defined in:
- lib/zakuro/merchant.rb
Overview
Merchant ざくろ商人
東西の暦を取引する、素敵な笑顔の持ち主
Constant Summary collapse
Instance Attribute Summary collapse
-
#condition ⇒ Parameter::Condition
readonly
条件.
Instance Method Summary collapse
-
#commit ⇒ Result::SingleDay, Result::Range
承諾する.
-
#initialize(condition: {}) ⇒ Merchant
constructor
初期化.
-
#offer(condition: {}) ⇒ Merchant
条件提示する.
Constructor Details
#initialize(condition: {}) ⇒ Merchant
初期化
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zakuro/merchant.rb', line 32 def initialize(condition: {}) failed = Parameter::Condition.validate(hash: condition) raise Exception.get(presets: failed) unless failed.empty? @condition = Parameter::Condition.new(hash: condition) rescue Exception::ZakuroError => e raise e rescue StandardError => e make_internal_error(error: e) end |
Instance Attribute Details
#condition ⇒ Parameter::Condition (readonly)
Returns 条件.
23 24 25 |
# File 'lib/zakuro/merchant.rb', line 23 def condition @condition end |
Instance Method Details
#commit ⇒ Result::SingleDay, Result::Range
承諾する
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/zakuro/merchant.rb', line 73 def commit context = Context::Context.new(options: condition.) result = get(context: context) return result.get unless result.invalid? make_uncommitable_error rescue Exception::ZakuroError => e raise e rescue StandardError => e make_internal_error(error: e) end |
#offer(condition: {}) ⇒ Merchant
条件提示する
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zakuro/merchant.rb', line 52 def offer(condition: {}) failed = Parameter::Condition.validate(hash: condition) raise Exception.get(presets: failed) unless failed.empty? condition.rewrite(hash: condition) self rescue Exception::ZakuroError => e raise e rescue StandardError => e make_internal_error(error: e) end |