Class: Parliament::Builder::OpenSearchResponseBuilder

Inherits:
BaseResponseBuilder
  • Object
show all
Defined in:
lib/parliament/builder/open_search_response_builder.rb

Overview

OpenSearch response builder using Feedjira to parse the response.

Since:

  • 0.1.0

Constant Summary collapse

OPEN_SEARCH_ELEMENTS =

Since:

  • 0.1.0

%w[totalResults Query startIndex itemsPerPage].freeze

Instance Method Summary collapse

Instance Method Details

#buildObject

Builds a Feedjira::Feed response. It adds the extra OpenSearch feed elements, then parses the HTTP Response.

Since:

  • 0.1.0



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/parliament/builder/open_search_response_builder.rb', line 10

def build
  OPEN_SEARCH_ELEMENTS.each do |element|
    Feedjira::Feed.add_common_feed_element(element)
  end

  # Add custom parser entries for hints
  Feedjira::Parser::AtomEntry.elements(:Name, as: :hint_types)

  # Custom parser for formatted link
  Feedjira::Parser::AtomEntry.element(:link, as: :formatted_url, value: :title)

  Feedjira::Feed.parse(@response.body)
end