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
930 931 932 933 |
# File 'lib/google4r/checkout/shared.rb', line 930 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.
923 924 925 |
# File 'lib/google4r/checkout/shared.rb', line 923 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.
928 929 930 |
# File 'lib/google4r/checkout/shared.rb', line 928 def shipping_packages @shipping_packages end |
Instance Method Details
#create_carrier_calculated_shipping_option {|option| ... } ⇒ Object
935 936 937 938 939 940 941 942 943 |
# File 'lib/google4r/checkout/shared.rb', line 935 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.
958 959 960 961 962 963 964 965 966 |
# File 'lib/google4r/checkout/shared.rb', line 958 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
945 946 947 948 949 950 951 952 953 |
# File 'lib/google4r/checkout/shared.rb', line 945 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 |