Class: Pennyworth::Loaders::HTMX
- Inherits:
-
Object
- Object
- Pennyworth::Loaders::HTMX
- Defined in:
- lib/pennyworth/loaders/htmx.rb
Overview
Loads htmx documentation by scraping web page.
Constant Summary collapse
- PARSER =
Ox.tap do |ox| ox. = {mode: :generic, effort: :tolerant, smart: true} end
Class Method Summary collapse
Instance Method Summary collapse
- #call(uri) ⇒ Object
-
#initialize(parser: PARSER, model: Models::HTMX) ⇒ HTMX
constructor
A new instance of HTMX.
Constructor Details
Class Method Details
.text_for(element) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/pennyworth/loaders/htmx.rb', line 19 def self.text_for element parts = element.each.with_object [] do |item, content| content.append item.is_a?(Ox::Element) ? "`#{item.text}`" : item end parts.join.up.delete_suffix "." end |
Instance Method Details
#call(uri) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/pennyworth/loaders/htmx.rb', line 33 def call uri read(uri).each.with_object [] do |row, entries| next unless row.locate("td") in Ox::Element => item, Ox::Element => description entries.append record_for(item, description, uri) end end |