Class: Google4R::Checkout::CarrierCalculatedShipping
- Inherits:
-
Object
- Object
- Google4R::Checkout::CarrierCalculatedShipping
- Defined in:
- lib/google4r/checkout/shared.rb
Overview
A class that represents the “merchant-calculated” shipping method
Defined Under Namespace
Classes: CarrierCalculatedShippingOption, ShippingPackage
Instance Attribute Summary collapse
-
#carrier_calculated_shipping_options ⇒ Object
readonly
This encapsulates information about all of the shipping methods for which Google Checkout should obtain shipping costs.
-
#shipping_packages ⇒ Object
readonly
This encapsulates information about all of the packages that will be shipped to the buyer.
Instance Method Summary collapse
- #create_carrier_calculated_shipping_option {|option| ... } ⇒ Object
-
#create_from_element(element) ⇒ Object
Creates a new CarrierCalculatedShipping from the given REXML::Element instance.
- #create_shipping_package {|package| ... } ⇒ Object
-
#initialize ⇒ CarrierCalculatedShipping
constructor
A new instance of CarrierCalculatedShipping.
Constructor Details
#initialize ⇒ CarrierCalculatedShipping
Returns a new instance of CarrierCalculatedShipping.
950 951 952 953 |
# File 'lib/google4r/checkout/shared.rb', line 950 def initialize() = Array.new @shipping_packages = Array.new end |
Instance Attribute Details
#carrier_calculated_shipping_options ⇒ Object (readonly)
This encapsulates information about all of the shipping methods for which Google Checkout should obtain shipping costs.
943 944 945 |
# File 'lib/google4r/checkout/shared.rb', line 943 def end |
#shipping_packages ⇒ Object (readonly)
This encapsulates information about all of the packages that will be shipped to the buyer. At this time, merchants may only specify one package per order.
948 949 950 |
# File 'lib/google4r/checkout/shared.rb', line 948 def shipping_packages @shipping_packages end |
Instance Method Details
#create_carrier_calculated_shipping_option {|option| ... } ⇒ Object
955 956 957 958 959 960 961 962 963 |
# File 'lib/google4r/checkout/shared.rb', line 955 def create_carrier_calculated_shipping_option(&block) option = CarrierCalculatedShippingOption.new(self) << option # Pass the newly generated rule to the given block to set its attributes. yield(option) if block_given? return option end |
#create_from_element(element) ⇒ Object
Creates a new CarrierCalculatedShipping from the given REXML::Element instance. For testing only.
978 979 980 981 982 983 984 985 986 |
# File 'lib/google4r/checkout/shared.rb', line 978 def create_from_element(element) result = CarrierCalculatedShipping.new element.elements.each('carrier-calculated-shipping-options/carrier-calculated-shipping-option') do |shipping_option_element| result. << CarrierCalculatedShippingOption.create_from_element(self, shipping_option_element) end element.elements.each('shipping-packages/shipping-package') do |shipping_package_element| result.shipping_packages << ShippingPackage.create_from_element(self, shipping_package_element) end end |
#create_shipping_package {|package| ... } ⇒ Object
965 966 967 968 969 970 971 972 973 |
# File 'lib/google4r/checkout/shared.rb', line 965 def create_shipping_package(&block) package = ShippingPackage.new(self) @shipping_packages << package # Pass the newly generated rule to the given block to set its attributes. yield(package) if block_given? return package end |