Class: FreightKit::Tariff
- Inherits:
-
Object
- Object
- FreightKit::Tariff
- Defined in:
- lib/freight_kit/tariff.rb
Instance Attribute Summary collapse
-
#overlength_rules ⇒ Object
Returns the value of attribute overlength_rules.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Tariff
constructor
A new instance of Tariff.
Constructor Details
#initialize(options = {}) ⇒ Tariff
Returns a new instance of Tariff.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/freight_kit/tariff.rb', line 7 def initialize( = {}) .symbolize_keys! @options = @options[:overlength_rules] = (@options[:overlength_rules].presence || []) raise ArgumentError, 'overlength_rules must be an Array' unless @options[:overlength_rules].is_a?(Array) @options[:overlength_rules].each do |overlength_rule| if !overlength_rule[:min_length].is_a?(Measured::Length) raise ArgumentError, 'overlength_rule[:min_length] must be a Measured::Length' elsif ![Measured::Length, NilClass].include?(overlength_rule[:max_length].class) raise ArgumentError, 'overlength_rule[:max_length] must be one of Measured::Length, NilClass' end unless overlength_rule[:fee_cents].is_a?(Integer) raise ArgumentError, 'overlength_rule[:fee_cents] must be an Integer' end end @overlength_rules = @options[:overlength_rules] end |
Instance Attribute Details
#overlength_rules ⇒ Object
Returns the value of attribute overlength_rules.
5 6 7 |
# File 'lib/freight_kit/tariff.rb', line 5 def overlength_rules @overlength_rules end |