Class: FloorCalculator::Solver
- Inherits:
-
Object
- Object
- FloorCalculator::Solver
- Defined in:
- lib/floor_calculator/solver.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#fast ⇒ Object
readonly
Returns the value of attribute fast.
-
#formula ⇒ Object
readonly
Returns the value of attribute formula.
-
#markups ⇒ Object
readonly
Returns the value of attribute markups.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Class Method Summary collapse
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(markups, markup_name, options) ⇒ Solver
constructor
A new instance of Solver.
Constructor Details
#initialize(markups, markup_name, options) ⇒ Solver
Returns a new instance of Solver.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/floor_calculator/solver.rb', line 12 def initialize(markups, markup_name, ) @markups = markups markup = markups.fetch(markup_name.to_s, {}) source_formula = source_markup(markup, [:source]) country_formula = country_markup(source_formula, [:country].to_s.downcase) @formula = destination_markup(country_formula, [:destination]) if @formula.nil? raise "Formula in #{markup_name.to_s} not found for: #{[:source]}, "\ "#{[:country].to_s.downcase}, #{[:destination]}" end @price = [:price] @weight = [:weight] @fast = [:fast] @condition = [:condition] end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
6 7 8 |
# File 'lib/floor_calculator/solver.rb', line 6 def condition @condition end |
#fast ⇒ Object (readonly)
Returns the value of attribute fast.
6 7 8 |
# File 'lib/floor_calculator/solver.rb', line 6 def fast @fast end |
#formula ⇒ Object (readonly)
Returns the value of attribute formula.
6 7 8 |
# File 'lib/floor_calculator/solver.rb', line 6 def formula @formula end |
#markups ⇒ Object (readonly)
Returns the value of attribute markups.
6 7 8 |
# File 'lib/floor_calculator/solver.rb', line 6 def markups @markups end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
6 7 8 |
# File 'lib/floor_calculator/solver.rb', line 6 def price @price end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
6 7 8 |
# File 'lib/floor_calculator/solver.rb', line 6 def weight @weight end |
Class Method Details
.calculate(markups, markup_name, options) ⇒ Object
8 9 10 |
# File 'lib/floor_calculator/solver.rb', line 8 def self.calculate(markups, markup_name, ) new(markups, markup_name, ).calculate end |
Instance Method Details
#calculate ⇒ Object
28 29 30 |
# File 'lib/floor_calculator/solver.rb', line 28 def calculate Dentaku.evaluate(formula, price: price, weight: weight, fast: fast, condition: condition) end |