Class: FriendlyShipping::ShippingMethod
- Inherits:
-
Object
- Object
- FriendlyShipping::ShippingMethod
- 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
-
#carrier ⇒ Carrier
readonly
This shipping method's carrier.
-
#data ⇒ Hash
readonly
Additional carrier-specific data for this shipping method.
-
#name ⇒ String
readonly
The shipping method's name.
-
#origin_countries ⇒ Array<String>
readonly
Countries this shipping method ships from.
-
#service_code ⇒ String
readonly
The shipping method's service code.
Instance Method Summary collapse
-
#domestic? ⇒ Boolean
Returns true if this is a domestic shipping method.
-
#initialize(name: nil, service_code: nil, domestic: nil, international: nil, multi_package: nil, carrier: nil, origin_countries: [], data: {}) ⇒ ShippingMethod
constructor
A new instance of ShippingMethod.
-
#international? ⇒ Boolean
Returns true if this is an international shipping method.
-
#multi_package? ⇒ Boolean
Returns true if this shipping method supports multiple packages.
Constructor Details
#initialize(name: nil, service_code: nil, domestic: nil, international: nil, multi_package: nil, carrier: nil, origin_countries: [], data: {}) ⇒ ShippingMethod
Returns a new instance of 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
#carrier ⇒ Carrier (readonly)
Returns this shipping method's carrier.
13 14 15 |
# File 'lib/friendly_shipping/shipping_method.rb', line 13 def carrier @carrier end |
#data ⇒ Hash (readonly)
Returns additional carrier-specific data for this shipping method.
19 20 21 |
# File 'lib/friendly_shipping/shipping_method.rb', line 19 def data @data end |
#name ⇒ String (readonly)
Returns the shipping method's name.
7 8 9 |
# File 'lib/friendly_shipping/shipping_method.rb', line 7 def name @name end |
#origin_countries ⇒ Array<String> (readonly)
Returns countries this shipping method ships from.
16 17 18 |
# File 'lib/friendly_shipping/shipping_method.rb', line 16 def origin_countries @origin_countries end |
#service_code ⇒ String (readonly)
Returns the shipping method's service code.
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 |