Class: Stall::Shipping::CountryWeightTableCalculator
- Inherits:
-
Calculator
- Object
- Calculator
- Stall::Shipping::CountryWeightTableCalculator
- Defined in:
- lib/stall/shipping/country_weight_table_calculator.rb
Instance Attribute Summary
Attributes inherited from Calculator
Instance Method Summary collapse
Methods inherited from Calculator
#eot_price, for, #initialize, register, #trackable?, #tracking_url, #vat_rate
Constructor Details
This class inherits a constructor from Stall::Shipping::Calculator
Instance Method Details
#available? ⇒ Boolean
6 7 8 |
# File 'lib/stall/shipping/country_weight_table_calculator.rb', line 6 def available? country?(address.country) end |
#price ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/stall/shipping/country_weight_table_calculator.rb', line 10 def price total_weight = cart.total_weight # Browse the data hash to find a suitable country code for the cart's # total weight if (prices = data[cart.shipping_address.country]) prices.each do |max_weight, price| return price if total_weight < max_weight end end # Return nil if no price was found nil end |