Sha256: d4a1b6c5a322f2595f654080d885e46461b444603f329aeb6985d4433607b46a

Contents?: true

Size: 582 Bytes

Versions: 2

Compression:

Stored size: 582 Bytes

Contents

module DeathAndTaxes
  class TaxInfo
    def initialize name, yml = nil
      @name = name
      parse yml if yml
    end
    
    def parse yml
      @versions = yml['versions'].collect do |version|
        TaxVersion.new(version)
      end
    end
    
    def cover? date
      @versions.any?{ |v| v.cover? date }
    end
    
    def build date
      if v = @versions.detect{ |version| version.cover?(date) }
        t = Tax.new :name => @name, :percentage => v.percentage
        t.tax = DeathAndTaxes.build(v.apply_on, date) if v.apply_on
        t
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
death_and_taxes-0.0.5 lib/death_and_taxes/tax_info.rb
death_and_taxes-0.0.4 lib/death_and_taxes/tax_info.rb