Class: FriendlyShipping::Carrier

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/carrier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, name: nil, code: nil, shipping_methods: [], balance: nil, data: {}) ⇒ Carrier

Returns a new instance of Carrier.

Parameters:

  • id (Integer) (defaults to: nil)

    The carrier’s ID

  • name (String) (defaults to: nil)

    The carrier’s name

  • code (String) (defaults to: nil)

    The carrier’s unique code

  • shipping_methods (Array) (defaults to: [])

    The shipping methods available on this carrier

  • balance (Float) (defaults to: nil)

    The remaining balance for this carrier

  • data (Hash) (defaults to: {})

    Additional data related to this carrier



13
14
15
16
17
18
19
20
# File 'lib/friendly_shipping/carrier.rb', line 13

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

#balanceObject (readonly)

Returns the value of attribute balance.



5
6
7
# File 'lib/friendly_shipping/carrier.rb', line 5

def balance
  @balance
end

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/friendly_shipping/carrier.rb', line 5

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/friendly_shipping/carrier.rb', line 5

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/friendly_shipping/carrier.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/friendly_shipping/carrier.rb', line 5

def name
  @name
end

#shipping_methodsObject (readonly)

Returns the value of attribute shipping_methods.



5
6
7
# File 'lib/friendly_shipping/carrier.rb', line 5

def shipping_methods
  @shipping_methods
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/friendly_shipping/carrier.rb', line 22

def ==(other)
  id == other.id
end