Class: Webpipe::Document
- Inherits:
-
Object
- Object
- Webpipe::Document
- Defined in:
- lib/webpipe/types.rb
Overview
Result of scraping a single page (scrape / browser / crawl data item).
metadata is a plain Hash — the API adds extra keys (og:*, sourceURL, ...).
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#raw_html ⇒ Object
readonly
Returns the value of attribute raw_html.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(markdown: nil, html: nil, raw_html: nil, links: nil, metadata: nil, json: nil) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(markdown: nil, html: nil, raw_html: nil, links: nil, metadata: nil, json: nil) ⇒ Document
Returns a new instance of Document.
16 17 18 19 20 21 22 23 |
# File 'lib/webpipe/types.rb', line 16 def initialize(markdown: nil, html: nil, raw_html: nil, links: nil, metadata: nil, json: nil) @markdown = markdown @html = html @raw_html = raw_html @links = links @metadata = @json = json end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
14 15 16 |
# File 'lib/webpipe/types.rb', line 14 def html @html end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
14 15 16 |
# File 'lib/webpipe/types.rb', line 14 def json @json end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
14 15 16 |
# File 'lib/webpipe/types.rb', line 14 def links @links end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
14 15 16 |
# File 'lib/webpipe/types.rb', line 14 def markdown @markdown end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
14 15 16 |
# File 'lib/webpipe/types.rb', line 14 def @metadata end |
#raw_html ⇒ Object (readonly)
Returns the value of attribute raw_html.
14 15 16 |
# File 'lib/webpipe/types.rb', line 14 def raw_html @raw_html end |
Class Method Details
.from_hash(hash) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/webpipe/types.rb', line 25 def self.from_hash(hash) hash ||= {} new( markdown: hash["markdown"], html: hash["html"], raw_html: hash["rawHtml"], links: hash["links"]&.map { |l| Link.from_hash(l) }, metadata: hash["metadata"], json: hash["json"] ) end |