floor_calculator 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0f48d804000fa4334d9a9cb29a2d06ff73c0f07
4
- data.tar.gz: 847a2a4c42515b3a15bd267caf6ef523b9583372
3
+ metadata.gz: 525994f2058fc47b37d0a407c86bf5e7e3f0694f
4
+ data.tar.gz: 7205f4ae35e4c5058177d4b0c65e27046593bb56
5
5
  SHA512:
6
- metadata.gz: a1e1ea32ba2e54418c31eb9f14d4dae7352e36cd7acfa2f85335966824f337219ae7336fb6f4669f95f5f3fba46a7b4564fb00809f377a9e0fe83e09b0b8c276
7
- data.tar.gz: 81a4ad5cbbfb21b0f51faf452dd274b4498aadec11eaaaf4a2911c2e33e58cac3cc60eab8ab9f675a42099a251e92d533d50984e27a8bc0fa29c7da93b5273a6
6
+ metadata.gz: 04f99fe1af0ca40e9e6a3f4a7bd370f302892796e2b8f35bb418ec891d6e07fea8bd59fcb2aceac2bc1fa245c6eec20b04125e0881b6c625c7724a08fafba419
7
+ data.tar.gz: 9a226d3dcf581e8e4b5981533b1fa95332d29a62a9eaff9f196b630f86ef63d3bdaf2c5687fb9d5ad535ae90a8e4c28efbb5d86dbbefbef8a8a4cd836534b5c5
@@ -3,6 +3,8 @@ require 'floor_calculator'
3
3
  module FloorCalculator
4
4
  class Pricer
5
5
  attr_reader :partial_results, :markups, :source_catalog, :destination, :offer, :weight
6
+ COST_METHODS = %i[cost_of_overheads cost_to_fill cost_to_ship cost_of_spoilage
7
+ minimum_profit cost_to_list].freeze
6
8
 
7
9
  def initialize(offer, weight, markups)
8
10
  @partial_results = {}
@@ -14,15 +16,13 @@ module FloorCalculator
14
16
  end
15
17
 
16
18
  def calculate_floor
17
- new_price = cost_to_fill(prepare_options(offer, offer.price))
18
- new_price = cost_to_ship(prepare_options(offer, new_price))
19
- new_price = cost_of_spoilage(prepare_options(offer, new_price))
20
- new_price = minimum_profit(prepare_options(offer, new_price))
21
- round_to_20s(cost_to_list(prepare_options(offer, new_price)).fractional)
19
+ floor = COST_METHODS.each_with_object(offer.price) do |method, price|
20
+ public_send(method, prepare_options(offer, price))
21
+ end
22
+ round_to_20s(floor.fractional)
22
23
  end
23
24
 
24
- %w(cost_to_list cost_to_fill cost_of_spoilage
25
- cost_to_ship minimum_profit).each do |method|
25
+ COST_METHODS.each do |method|
26
26
  define_method method do |options|
27
27
  calculated_value =
28
28
  Solver.calculate(markups, method, options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floor_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Mikołajczyk