Class: Taxedo::Builder::Hash

Inherits:
Base
  • Object
show all
Defined in:
lib/taxedo/builder/hash.rb

Direct Known Subclasses

Json

Instance Method Summary collapse

Methods inherited from Base

#initialize, #price, #subtotal, #t, #taxes, #total

Constructor Details

This class inherits a constructor from Taxedo::Builder::Base

Instance Method Details

#generateObject



2
3
4
# File 'lib/taxedo/builder/hash.rb', line 2

def generate
  { subtotal: subtotal, taxes: generate_taxes, total: total }
end

#generate_tax(tax) ⇒ Object



10
11
12
# File 'lib/taxedo/builder/hash.rb', line 10

def generate_tax(tax)
  { id: tax.id, name: tax.name, amount: tax.amount }
end

#generate_taxesObject



6
7
8
# File 'lib/taxedo/builder/hash.rb', line 6

def generate_taxes
  taxes.map{ |t| generate_tax t }
end