Class: Pennyworth::Loaders::RFC

Inherits:
Object
  • Object
show all
Defined in:
lib/pennyworth/loaders/rfc.rb

Overview

Loads RFC records by scraping web page.

Instance Method Summary collapse

Constructor Details

#initialize(parser: Nokogiri::HTML5, model: Models::RFC) ⇒ RFC

Returns a new instance of RFC.



12
13
14
15
16
# File 'lib/pennyworth/loaders/rfc.rb', line 12

def initialize(parser: Nokogiri::HTML5, model: Models::RFC, **)
  @parser = parser
  @model = model
  super(**)
end

Instance Method Details

#call(uri) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/pennyworth/loaders/rfc.rb', line 18

def call uri
  fetch(uri).then { parse_rows it }
            .each
            .with_object [] do |row, entries|
    row.children in Nokogiri::XML::Element => label,
                   Nokogiri::XML::Element => description,
                   Nokogiri::XML::Element => published
    entries.append build_record(label, description, published)
  end
end