Class: Ecfr::RendererService::Content

Inherits:
Base show all
Defined in:
lib/ecfr/renderer_service/content.rb

Constant Summary

Constants inherited from Base

Base::HTML_PATH

Constants inherited from Base

Base::SUPPORTED_ARRAY_ACCESSORS

Instance Attribute Summary collapse

Attributes inherited from Base

#metadata, #request_data, #response_status, #results

Class Method Summary collapse

Methods inherited from Base

base_url, service_name, service_path

Methods inherited from Base

basic_auth_client_options, #each, #initialize, metadata, metadata_key, result_key

Methods included from Extensible

#inherited

Methods included from AttributeMethodDefinition

included, #initialize

Methods inherited from Client

build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge

Methods included from ParallelClient

included

Constructor Details

This class inherits a constructor from Ecfr::Base

Instance Attribute Details

#htmlString (readonly)

HTML document

Returns:

  • (String)


4
5
# File 'lib/ecfr/renderer_service/content.rb', line 4

attribute :html,
desc: "HTML document"

Class Method Details

.find(date, hierarchy, options = {}, client_options: {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ecfr/renderer_service/content.rb', line 7

def self.find(date, hierarchy, options = {}, client_options: {})
  hierarchy = hierarchy.dup

  title = hierarchy.delete(:title)
  view_mode = options.delete(:view_mode)

  complete = hierarchy.delete(:complete)
  options[:skip_ancestry_checks] = 1 if complete

  new(
    {
      html: get(
        content_path(date, title, view_mode: view_mode),
        hierarchy.merge(options),
        client_options
      ).body
    }.stringify_keys
  )
end

.url_for(date, title_number, view_mode: "enhanced", params: {}) ⇒ Object



27
28
29
30
31
# File 'lib/ecfr/renderer_service/content.rb', line 27

def self.url_for(date, title_number, view_mode: "enhanced", params: {})
  path = content_path(date, title_number, view_mode: view_mode)

  client.build_url(path, params).to_s
end