Sha256: 538f0b32c5c487a517607f5268bf2e4ace4cd1fc4f9da785bd7fb12328d9248c

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 Bytes

Contents

module DeathAndTaxes
  class TaxInfo
    def initialize name, yml = nil
      @name = name
      parse yml if yml
    end
    
    def parse yml
      @apply_on = yml['apply_on']
      @versions = yml['versions'].collect do |version|
        TaxVersion.new(version)
      end
    end
    
    def cover? date
      @versions.any?{ |version| v.cover? date }
    end
    
    def build date
      if v = @versions.detect{ |v| v.cover?(date) }
        t = Tax.new :name => @name, :percentage => v['percentage']
        t.tax = DeathAndTaxes.build_tax(@apply_on, date) if @apply_on
        t
      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/tax_info.rb
death_and_taxes-0.0.2 lib/death_and_taxes/tax_info.rb