Class: AbnLookup::Abn

Inherits:
Object
  • Object
show all
Defined in:
lib/abn_lookup/abn.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#abnObject

Returns the value of attribute abn.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def abn
  @abn
end

#abn_statusObject

Returns the value of attribute abn_status.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def abn_status
  @abn_status
end

#abn_status_effective_fromObject

Returns the value of attribute abn_status_effective_from.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def abn_status_effective_from
  @abn_status_effective_from
end

#acnObject

Returns the value of attribute acn.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def acn
  @acn
end

#address_dateObject

Returns the value of attribute address_date.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def address_date
  @address_date
end

#address_postcodeObject

Returns the value of attribute address_postcode.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def address_postcode
  @address_postcode
end

#address_stateObject

Returns the value of attribute address_state.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def address_state
  @address_state
end

#business_nameObject

Returns the value of attribute business_name.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def business_name
  @business_name
end

#entity_nameObject

Returns the value of attribute entity_name.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def entity_name
  @entity_name
end

#entity_type_codeObject

Returns the value of attribute entity_type_code.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def entity_type_code
  @entity_type_code
end

#entity_type_nameObject

Returns the value of attribute entity_type_name.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def entity_type_name
  @entity_type_name
end

#gstObject

Returns the value of attribute gst.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def gst
  @gst
end

#messageObject

Returns the value of attribute message.



3
4
5
# File 'lib/abn_lookup/abn.rb', line 3

def message
  @message
end

Class Method Details

.parse(data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/abn_lookup/abn.rb', line 15

def self.parse(data)
  abn = Abn.new

  # Transforming PascalCase to snake_case
  snake_case = data.each_with_object({}) do |(key, value), new_hash|
    new_key = key.to_s.gsub(/([A-Z])/, '_\1').downcase
    new_hash[new_key.sub(/^_/, '').to_sym] = value
  end

  snake_case.each do |key, value|
    abn.send("#{key}=", value) if abn.respond_to?("#{key}=")
  end

  abn
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/abn_lookup/abn.rb', line 7

def active?
  abn_status == "Active"
end

#inspectObject



11
12
13
# File 'lib/abn_lookup/abn.rb', line 11

def inspect
  "#<#{self.class.name}:0x#{object_id} @abn=\"#{abn}\" @acn=\"#{acn}\" @active=#{active?} @gst=\"#{gst}\" @entity_name=\"#{entity_name}\">"
end