Sha256: 53704b7a4e44ceb17bc6e3179c6332493b65fd3808d037ae01fc9fb9449a158d

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 Bytes

Contents

module ActiveTax
  class Tax
    attr_accessor :state, :api_class

    def self.rate(address={})
      raise StandardError, "You must provide a state to use ActiveTax::Tax.rate" unless address[:state]
      self.new(address[:state]).rate_from_address(address)
    end

    def initialize(state)
      self.state = state
    end

    def rate_from_address(address={})
      self.state = address[:state] if address[:state]

      case self.state.upcase
      when "WA", "WASHINGTON"
        self.api_class = States::WA
      else
        raise StandardError, "API for #{self.state.upcase} not yet implemented in ActiveTax."
      end

      self.api_class.rate(address)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_tax-0.2.0 lib/active_tax/tax.rb