Class: WhosGotDirt::Responses::Entity::LittleSis
- Inherits:
-
Helpers::LittleSisHelper
- Object
- SimpleDelegator
- WhosGotDirt::Response
- Helpers::LittleSisHelper
- WhosGotDirt::Responses::Entity::LittleSis
- Defined in:
- lib/whos_got_dirt/responses/entity/little_sis.rb
Overview
Converts entities from the LittleSis API to Popolo format.
Instance Method Summary collapse
-
#item_url(result) ⇒ String
Returns an entity'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 an entity's URL.
72 73 74 75 |
# File 'lib/whos_got_dirt/responses/entity/little_sis.rb', line 72 def item_url(result) query = CGI.parse(env.url.query.to_s) "#{env.url.scheme}://#{env.url.host}/entity/#{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.
58 59 60 61 62 63 64 65 66 |
# File 'lib/whos_got_dirt/responses/entity/little_sis.rb', line 58 def to_a list = parsed_body['Data']['Entities']['Entity'] if Hash === list list = [list] end list.map do |data| Result.new('Entity', renderer.result(data), self).finalize! end end |