Class: FriendlyShipping::ShippingMethod

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

Overview

Represents a shipping method (UPS Ground, USPS Priority, etc.) that belongs to a Carrier.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, service_code: nil, domestic: nil, international: nil, multi_package: nil, carrier: nil, origin_countries: [], data: {}) ⇒ ShippingMethod



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/friendly_shipping/shipping_method.rb', line 29

def initialize(
  name: nil,
  service_code: nil,
  domestic: nil,
  international: nil,
  multi_package: nil,
  carrier: nil,
  origin_countries: [],
  data: {}
)
  @name = name
  @service_code = service_code
  @domestic = domestic
  @international = international
  @multi_package = multi_package
  @carrier = carrier
  @origin_countries = origin_countries
  @data = data
end

Instance Attribute Details

#carrierCarrier (readonly)



13
14
15
# File 'lib/friendly_shipping/shipping_method.rb', line 13

def carrier
  @carrier
end

#dataHash (readonly)



19
20
21
# File 'lib/friendly_shipping/shipping_method.rb', line 19

def data
  @data
end

#nameString (readonly)



7
8
9
# File 'lib/friendly_shipping/shipping_method.rb', line 7

def name
  @name
end

#origin_countriesArray<String> (readonly)



16
17
18
# File 'lib/friendly_shipping/shipping_method.rb', line 16

def origin_countries
  @origin_countries
end

#service_codeString (readonly)



10
11
12
# File 'lib/friendly_shipping/shipping_method.rb', line 10

def service_code
  @service_code
end

Instance Method Details

#domestic?Boolean

Returns true if this is a domestic shipping method.



51
52
53
# File 'lib/friendly_shipping/shipping_method.rb', line 51

def domestic?
  !!domestic
end

#international?Boolean

Returns true if this is an international shipping method.



57
58
59
# File 'lib/friendly_shipping/shipping_method.rb', line 57

def international?
  !!international
end

#multi_package?Boolean

Returns true if this shipping method supports multiple packages.



63
64
65
# File 'lib/friendly_shipping/shipping_method.rb', line 63

def multi_package?
  !!multi_package
end