Sha256: ec9f9a1dd7abf19db3bb8f4829a00b38bfbd79eec8760922cf43e55aff55ffcb
Contents?: true
Size: 778 Bytes
Versions: 2
Compression:
Stored size: 778 Bytes
Contents
module DeathAndTaxes class State def initialize code, yml = nil @taxes = {} @code = code parse yml if yml end def parse yml ## # Builds a tax list for each taxes defined in this state yml['taxes'].each do |tax_name, infos| @taxes[tax_name] = TaxInfo.new(tax_name, infos) end @rules = yml['rules'] end def applicable_taxes to_state, date taxes = if to_state == @code && @rules['same_state'] @rules['same_state'] elsif @rules['same_country'] @rules['same_country'] else [] end [taxes].flatten end def build_tax tax, date if i = @taxes[tax] && i.cover?(date) i.build(date) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
death_and_taxes-0.0.3 | lib/death_and_taxes/state.rb |
death_and_taxes-0.0.2 | lib/death_and_taxes/state.rb |