Class: Spree::ShippingRate

Inherits:
Struct
  • Object
show all
Defined in:
app/models/spree/shipping_rate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ShippingRate

Returns a new instance of ShippingRate.



3
4
5
6
7
# File 'app/models/spree/shipping_rate.rb', line 3

def initialize(attributes = {})
  attributes.each do |k, v|
    self.send("#{k}=", v)
  end
end

Instance Attribute Details

#costObject

Returns the value of attribute cost

Returns:

  • (Object)

    the current value of cost



2
3
4
# File 'app/models/spree/shipping_rate.rb', line 2

def cost
  @cost
end

#currencyObject

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



2
3
4
# File 'app/models/spree/shipping_rate.rb', line 2

def currency
  @currency
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



2
3
4
# File 'app/models/spree/shipping_rate.rb', line 2

def id
  @id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'app/models/spree/shipping_rate.rb', line 2

def name
  @name
end

#shipping_methodObject

Returns the value of attribute shipping_method

Returns:

  • (Object)

    the current value of shipping_method



2
3
4
# File 'app/models/spree/shipping_rate.rb', line 2

def shipping_method
  @shipping_method
end

Instance Method Details

#display_priceObject



9
10
11
12
13
14
15
16
17
# File 'app/models/spree/shipping_rate.rb', line 9

def display_price
  if Spree::Config[:shipment_inc_vat]
    price = (1 + Spree::TaxRate.default) * cost
  else
    price = cost
  end

  Spree::Money.new(price, { :currency => currency })
end