Sha256: 119e1bf5ce07a2e7e3249811a5d18cb54969a3f13a6da925108480f225b592ba

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 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"
        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.1.0 lib/active_tax/tax.rb