class Composer

Attributes

current_demand[RW]
demand_methods[RW]
total[RW]

Public Class Methods

new(taxgirl_block) click to toggle source
# File lib/tax_girl/composer.rb, line 6
def initialize(taxgirl_block)
  @demand_methods = { discount: { currency: [], percentage: [] }, increase: { currency: [], percentage: [] } }
  @current_demand = nil
  @taxgirl_block = taxgirl_block
  @total = 0
end

Public Instance Methods

currency(*args) click to toggle source
# File lib/tax_girl/composer.rb, line 29
def currency(*args)
  demand_methods[current_demand][:currency] = args
end
discount() { || ... } click to toggle source
# File lib/tax_girl/composer.rb, line 23
def discount
  @current_demand = :discount

  yield
end
evaluate!() click to toggle source
# File lib/tax_girl/composer.rb, line 13
def evaluate!
  instance_eval(&@taxgirl_block)
end
increase() { || ... } click to toggle source
# File lib/tax_girl/composer.rb, line 17
def increase
  @current_demand = :increase

  yield
end
percentage(*args) click to toggle source
# File lib/tax_girl/composer.rb, line 33
def percentage(*args)
  demand_methods[current_demand][:percentage] = args
end