Class: FriendlyShipping::Carrier
- Inherits:
-
Object
- Object
- FriendlyShipping::Carrier
- Defined in:
- lib/friendly_shipping/carrier.rb
Overview
Represents a carrier (UPS, FedEx, etc.) and its ShippingMethod objects.
Instance Attribute Summary collapse
-
#balance ⇒ Float
readonly
The remaining balance for this carrier.
-
#code ⇒ String
readonly
The carrier's unique code.
-
#data ⇒ Hash
readonly
Additional data related to this carrier.
-
#id ⇒ String
readonly
A unique identifier for this carrier.
-
#name ⇒ String
readonly
The carrier's name.
-
#shipping_methods ⇒ Array<ShippingMethod>
readonly
The shipping methods available on this carrier.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Returns true if the given object shares the same ID with this carrier.
-
#initialize(id: nil, name: nil, code: nil, shipping_methods: [], balance: nil, data: {}) ⇒ Carrier
constructor
A new instance of Carrier.
Constructor Details
#initialize(id: nil, name: nil, code: nil, shipping_methods: [], balance: nil, data: {}) ⇒ Carrier
Returns a new instance of Carrier.
30 31 32 33 34 35 36 37 |
# File 'lib/friendly_shipping/carrier.rb', line 30 def initialize(id: nil, name: nil, code: nil, shipping_methods: [], balance: nil, data: {}) @id = id @name = name @code = code @shipping_methods = shipping_methods @balance = balance @data = data end |
Instance Attribute Details
#balance ⇒ Float (readonly)
Returns the remaining balance for this carrier.
19 20 21 |
# File 'lib/friendly_shipping/carrier.rb', line 19 def balance @balance end |
#code ⇒ String (readonly)
Returns the carrier's unique code.
13 14 15 |
# File 'lib/friendly_shipping/carrier.rb', line 13 def code @code end |
#data ⇒ Hash (readonly)
Returns additional data related to this carrier.
22 23 24 |
# File 'lib/friendly_shipping/carrier.rb', line 22 def data @data end |
#id ⇒ String (readonly)
Returns a unique identifier for this carrier.
7 8 9 |
# File 'lib/friendly_shipping/carrier.rb', line 7 def id @id end |
#name ⇒ String (readonly)
Returns the carrier's name.
10 11 12 |
# File 'lib/friendly_shipping/carrier.rb', line 10 def name @name end |
#shipping_methods ⇒ Array<ShippingMethod> (readonly)
Returns the shipping methods available on this carrier.
16 17 18 |
# File 'lib/friendly_shipping/carrier.rb', line 16 def shipping_methods @shipping_methods end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if the given object shares the same ID with this carrier.
42 43 44 |
# File 'lib/friendly_shipping/carrier.rb', line 42 def ==(other) id == other.id end |