Class: CompaniesHouse::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/companies_house/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



7
8
9
10
# File 'lib/companies_house/response.rb', line 7

def initialize(response)
  check_for_errors(response)
  parse_response(response)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/companies_house/response.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#[](key) ⇒ Object

So that you can call attributes on the companies house object: company



25
26
27
# File 'lib/companies_house/response.rb', line 25

def [](key)
  @attributes[key]
end

#sic_codeObject

Return a SIC code from the ugly hash

company.sic_code

> “62090”



17
18
19
20
21
# File 'lib/companies_house/response.rb', line 17

def sic_code
  if self["SICCodes"] && self["SICCodes"]["SicText"]
    self["SICCodes"]["SicText"].first.split[0]
  end
end