Class: WhosGotDirt::Responses::List::LittleSis
- Inherits:
-
Helpers::LittleSisHelper
- Object
- SimpleDelegator
- WhosGotDirt::Response
- Helpers::LittleSisHelper
- WhosGotDirt::Responses::List::LittleSis
- Defined in:
- lib/whos_got_dirt/responses/list/little_sis.rb
Overview
Converts lists from the OpenCorporates API to Popolo format.
Instance Method Summary collapse
-
#item_url(result) ⇒ String
Returns a list's URL.
-
#to_a ⇒ Array<Hash>
Transforms the parsed response body into results.
Constructor Details
This class inherits a constructor from WhosGotDirt::Response
Instance Method Details
#item_url(result) ⇒ String
Returns a list's URL.
48 49 50 51 |
# File 'lib/whos_got_dirt/responses/list/little_sis.rb', line 48 def item_url(result) query = CGI.parse(env.url.query.to_s) "#{env.url.scheme}://#{env.url.host}/list/#{result['identifiers'][0]['identifier']}.xml?_key=#{CGI.escape(query['_key'][0].to_s)}" end |
#to_a ⇒ Array<Hash>
Transforms the parsed response body into results.
34 35 36 37 38 39 40 41 42 |
# File 'lib/whos_got_dirt/responses/list/little_sis.rb', line 34 def to_a list = parsed_body['Data']['Lists']['List'] if Hash === list list = [list] end list.map do |data| Result.new('List', renderer.result(data), self).finalize! end end |