Class: Strikeiron::Jurisdiction

Inherits:
Object
  • Object
show all
Defined in:
lib/strikeiron2/jurisdiction.rb

Overview

Jurisdiction represents a breakdown of the tax calculations for the taxable region(s).

Attributes

  • fips - The code assigned by the Federal Government or state agencies to uniquely identify a location.

  • name - Name associated to the corresponding FIPS code.

  • tax_amount - Sales tax rate for the corresponding FIPS code.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_values = {}) ⇒ Jurisdiction

Creates a Jurisdiction with the supplied attributes.



12
13
14
15
16
17
18
19
# File 'lib/strikeiron2/jurisdiction.rb', line 12

def initialize(default_values = {})
  safe_keys = %w(fips name tax_amount)
  
  default_values.each do |key, value|
    next unless safe_keys.include? key.to_s # Only permit the keys defined in safe_keys
    self.send "#{key}=", value
  end
end

Instance Attribute Details

#fipsObject

Returns the value of attribute fips.



9
10
11
# File 'lib/strikeiron2/jurisdiction.rb', line 9

def fips
  @fips
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/strikeiron2/jurisdiction.rb', line 9

def name
  @name
end

#tax_amountObject

Returns the value of attribute tax_amount.



9
10
11
# File 'lib/strikeiron2/jurisdiction.rb', line 9

def tax_amount
  @tax_amount
end

Class Method Details

.from_soap(hash = {}) ⇒ Object

Convert the SOAP response object to a Jurisdiction



22
23
24
25
26
27
28
29
30
# File 'lib/strikeiron2/jurisdiction.rb', line 22

def self.from_soap(hash = {})
  default_values = {
    :fips       => hash['FIPS'],
    :name       => hash['Name'],
    :tax_amount => hash['SalesTaxAmount']
  }

  new(default_values)
end