Class: NNEClient::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/nne_client/result.rb

Overview

The Result is used to represent a single result from a result set. It can be seen roughly as an NNE CompanyBasic object. It provides transparent loading of attributes from the NNE Company object. It also provides methods for navigating the API further.

The Result can be instantiated with either a full result hash from an API query or with just a tdc_id in which case the attributes will be lazy loaded from the API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ad_protectionObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#cvr_noObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#districtObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#emailObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#founded_yearObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#homepageObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#number_of_employeesObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#official_nameObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#p_noObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#phoneObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#status_textObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#streetObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

#tdf_nameObject (readonly)



60
61
# File 'lib/nne_client/result.rb', line 60

extended_attributes :email, :homepage, :founded_year,
:number_of_employees, :tdf_name, :status_text

#zip_codeObject (readonly)



51
52
# File 'lib/nne_client/result.rb', line 51

basic_attributes :cvr_no, :p_no, :district, :phone, :street, :zip_code,
:official_name, :ad_protection

Instance Method Details

#==(other) ⇒ Object



123
124
125
# File 'lib/nne_client/result.rb', line 123

def ==(other)
  other.tdc_id == tdc_id
end

#additional_namesObject

List of additional_names



68
69
70
71
# File 'lib/nne_client/result.rb', line 68

def additional_names
  result = Fetch.new(tdc_id, :fetch_company_additional_names).result_set.to_hash
  Array(result[:array_ofstring][:item])
end

#associatesObject

List of associates



84
85
86
87
88
89
90
91
# File 'lib/nne_client/result.rb', line 84

def associates
  subsidiaries = fetch_associates
  if subsidiaries.kind_of?(Hash)
    [Subsidiary.new(subsidiaries)]
  else
    subsidiaries.map{|subsidiary| Subsidiary.new(subsidiary) }
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/nne_client/result.rb', line 131

def eql?(other)
  hash == other.hash
end

#financesObject

List of finance records



114
115
116
117
118
119
120
121
# File 'lib/nne_client/result.rb', line 114

def finances
  finances = fetch_finances
  if finances.kind_of?(Hash)
    [Finance.new(finances)]
  else
    finances.map{|finance| Finance.new(finance) }
  end
end

#hashObject



127
128
129
# File 'lib/nne_client/result.rb', line 127

def hash
  tdc_id.hash
end

#house_noObject



63
64
65
# File 'lib/nne_client/result.rb', line 63

def house_no
  fetch_extended_attributes.fetch(:kvh, {}).fetch(:house_no, nil)
end

#ownershipsObject

List of ownerships



94
95
96
97
98
99
100
101
# File 'lib/nne_client/result.rb', line 94

def ownerships
  ownerships = fetch_ownerships
  if ownerships.kind_of?(Hash)
    [Ownership.new(ownerships)]
  else
    ownerships.map{|ownership| Ownership.new(ownership) }
  end
end

#subsidiariesObject

List of subsidiaries



104
105
106
107
108
109
110
111
# File 'lib/nne_client/result.rb', line 104

def subsidiaries
  subsidiaries = fetch_subsidiaries
  if subsidiaries.kind_of?(Hash)
    [Subsidiary.new(subsidiaries)]
  else
    subsidiaries.map{|subsidiary| Subsidiary.new(subsidiary) }
  end
end

#tradesObject

List of trades



74
75
76
77
78
79
80
81
# File 'lib/nne_client/result.rb', line 74

def trades
  trades = Fetch.new(tdc_id, :fetch_company_trade).result_set.to_hash[:trade] || []
  if trades.kind_of?(Hash)
    [Trade.new(trades)]
  else
    trades.map{|trade| Trade.new(trade) }
  end
end