Class: Fassbinder::ShippingBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/fassbinder/shipping_builder.rb

Constant Summary collapse

DEFAULT_SHIPPING_CENTS =
{ 'amazon.com'   => 399,
'amazon.co.uk' => 280,
'amazon.de'    => 299,
'amazon.ca'    => 649,
'amazon.fr'    => 300,
'amazon.co.jp' => 25000 }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeShippingBuilder

Returns a new instance of ShippingBuilder.



12
13
14
# File 'lib/fassbinder/shipping_builder.rb', line 12

def initialize
  @shipping = Kosher::Shipping.new
end

Instance Attribute Details

#shippingObject (readonly)

Returns the value of attribute shipping.



10
11
12
# File 'lib/fassbinder/shipping_builder.rb', line 10

def shipping
  @shipping
end

Instance Method Details

#add_availability(hours) ⇒ Object



16
17
18
19
20
# File 'lib/fassbinder/shipping_builder.rb', line 16

def add_availability(hours)
  availability = Kosher::Availability.new
  availability.hours = hours.to_i
  @shipping.availability = availability
end

#calculate_price(is_free, venue, currency) ⇒ Object



22
23
24
25
# File 'lib/fassbinder/shipping_builder.rb', line 22

def calculate_price(is_free, venue, currency)
  @shipping.cents = is_free ? 0 : DEFAULT_SHIPPING_CENTS[venue]
  @shipping.currency = currency
end