Class: Google4R::Checkout::TaxTable
- Inherits:
-
Object
- Object
- Google4R::Checkout::TaxTable
- Defined in:
- lib/google4r/checkout/shared.rb
Overview
A TaxTable is an ordered array of TaxRule objects. You should create the TaxRule instances using #create_rule
You must set up a tax table factory and should only create tax tables from within its temporal factory method as described in the class documentation of Frontend.
Each tax table must have one or more tax rules.
Example
include Google4R::Checkout
tax_free_table = TaxTable.new(false)
tax_free_table.name = "default table"
tax_free_table.create_rule do |rule|
rule.area = UsCountryArea.new(UsCountryArea::ALL)
rule.rate = 0.0
end
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of this tax table (string, required).
-
#rules ⇒ Object
readonly
An Array of the TaxRule objects that this TaxTable contains.
-
#standalone ⇒ Object
readonly
Boolean, true iff the table's standalone attribute is to be set to "true".
Instance Method Summary collapse
-
#create_rule {|rule| ... } ⇒ Object
Use this method to add a new TaxRule to the table.
-
#initialize(standalone) ⇒ TaxTable
constructor
A new instance of TaxTable.
Constructor Details
#initialize(standalone) ⇒ TaxTable
592 593 594 595 596 |
# File 'lib/google4r/checkout/shared.rb', line 592 def initialize(standalone) @rules = Array.new @standalone = standalone end |
Instance Attribute Details
#name ⇒ Object
The name of this tax table (string, required).
583 584 585 |
# File 'lib/google4r/checkout/shared.rb', line 583 def name @name end |
#rules ⇒ Object (readonly)
An Array of the TaxRule objects that this TaxTable contains. Use #create_rule do add to this Array but do not change it directly.
587 588 589 |
# File 'lib/google4r/checkout/shared.rb', line 587 def rules @rules end |
#standalone ⇒ Object (readonly)
Boolean, true iff the table's standalone attribute is to be set to "true".
590 591 592 |
# File 'lib/google4r/checkout/shared.rb', line 590 def standalone @standalone end |
Instance Method Details
#create_rule {|rule| ... } ⇒ Object
Use this method to add a new TaxRule to the table. If you use a block with this method then the block will called with the newly created rule for the parameter. The method will return the new rule in any case.
601 602 603 604 605 606 607 608 609 |
# File 'lib/google4r/checkout/shared.rb', line 601 def create_rule(&block) rule = TaxRule.new(self) @rules << rule # Pass the newly generated rule to the given block to set its attributes. yield(rule) if block_given? return rule end |