Class: WebStruct::Page
- Inherits:
-
Object
- Object
- WebStruct::Page
- Defined in:
- lib/webstruct/page.rb,
lib/webstruct/page/content.rb,
lib/webstruct/page/csv_header_sniffer.rb
Overview
Parsed HTTP response exposed to callers (text, optional structured data, and metadata).
Defined Under Namespace
Modules: CsvHeaderSniffer Classes: Content
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
-
#initialize(response, type) ⇒ Page
constructor
Wraps a Faraday response: decodes charset when possible, classifies MIME, and parses body text.
Constructor Details
#initialize(response, type) ⇒ Page
Wraps a Faraday response: decodes charset when possible, classifies MIME, and parses body text.
15 16 17 18 19 20 21 22 |
# File 'lib/webstruct/page.rb', line 15 def initialize(response, type) @content_type = Http::ContentType.normalize(response.headers["content-type"]) @content = Content.new( response.body.to_s, response.headers["content-type"].to_s, type ) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
9 10 11 |
# File 'lib/webstruct/page.rb', line 9 def content @content end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
9 10 11 |
# File 'lib/webstruct/page.rb', line 9 def content_type @content_type end |