floor_calculator 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/floor_calculator/pricer.rb +1 -0
- data/lib/floor_calculator/solver.rb +10 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8545db4c50032048bbb5848243c2ec1d0e4cee70
|
4
|
+
data.tar.gz: 386510178eed75014f1a78faf3444f1c8af62676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad9a4853bc96963413eaaa0223076084ac8ba9cf494f5581d67c5c1ce22bd22f558d16b4cff58d58f217b51f8a1029bc5ca98a9845c878c9181da15a02946fb0
|
7
|
+
data.tar.gz: 18879e8286cb8fc9619ca64897105329d9c4d5944124211f2b74a44a30003744b1fe45f03398b0aa12c84410739812b9bec61176e1e1d01cb33b1ddadb2f08c2
|
@@ -13,8 +13,12 @@ module FloorCalculator
|
|
13
13
|
@markups = markups
|
14
14
|
markup = markups.fetch(markup_name.to_s, {})
|
15
15
|
source_formula = source_markup(markup, options[:source])
|
16
|
-
|
17
|
-
|
16
|
+
country_formula = country_markup(source_formula, options[:country].to_s.downcase)
|
17
|
+
@formula = destination_markup(country_formula, options[:destination])
|
18
|
+
if @formula.nil?
|
19
|
+
raise "Formula not found for: #{options[:source]}, "\
|
20
|
+
"#{options[:country].to_s.downcase}, #{options[:destination]}"
|
21
|
+
end
|
18
22
|
@price = options[:price]
|
19
23
|
@weight = options[:weight]
|
20
24
|
@fast = options[:fast]
|
@@ -34,6 +38,10 @@ module FloorCalculator
|
|
34
38
|
result
|
35
39
|
end
|
36
40
|
|
41
|
+
def country_markup(source, country)
|
42
|
+
source.fetch(country) { source.fetch('default', {}) }
|
43
|
+
end
|
44
|
+
|
37
45
|
def destination_markup(source, destination)
|
38
46
|
source.fetch(destination) { source.fetch('default', nil) }
|
39
47
|
end
|