Class: Spidy::Connector::Lightpanda::LightpandaPage
- Inherits:
-
Object
- Object
- Spidy::Connector::Lightpanda::LightpandaPage
- Defined in:
- lib/spidy/connector/lightpanda.rb
Overview
Page-like object that mimics the Mechanize::Page interface
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #at ⇒ Object
- #css ⇒ Object
- #encoding ⇒ Object
-
#initialize(url, html_content) ⇒ LightpandaPage
constructor
A new instance of LightpandaPage.
-
#search ⇒ Object
Common methods from Mechanize::Page that might be used in the application.
- #try(*args) ⇒ Object
- #xpath ⇒ Object
Constructor Details
#initialize(url, html_content) ⇒ LightpandaPage
Returns a new instance of LightpandaPage.
127 128 129 130 131 132 133 134 |
# File 'lib/spidy/connector/lightpanda.rb', line 127 def initialize(url, html_content) @uri = url @body = html_content @doc = Nokogiri::HTML(html_content) @title = @doc.title @code = '200' @response_code = '200' end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
125 126 127 |
# File 'lib/spidy/connector/lightpanda.rb', line 125 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
125 126 127 |
# File 'lib/spidy/connector/lightpanda.rb', line 125 def code @code end |
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
125 126 127 |
# File 'lib/spidy/connector/lightpanda.rb', line 125 def response_code @response_code end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
125 126 127 |
# File 'lib/spidy/connector/lightpanda.rb', line 125 def title @title end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
125 126 127 |
# File 'lib/spidy/connector/lightpanda.rb', line 125 def uri @uri end |
Instance Method Details
#at ⇒ Object
141 142 143 |
# File 'lib/spidy/connector/lightpanda.rb', line 141 def at(*) @doc.at(*) end |
#css ⇒ Object
145 146 147 |
# File 'lib/spidy/connector/lightpanda.rb', line 145 def css(*) @doc.css(*) end |
#encoding ⇒ Object
153 154 155 |
# File 'lib/spidy/connector/lightpanda.rb', line 153 def encoding @doc.encoding end |
#search ⇒ Object
Common methods from Mechanize::Page that might be used in the application
137 138 139 |
# File 'lib/spidy/connector/lightpanda.rb', line 137 def search(*) @doc.search(*) end |
#try(*args) ⇒ Object
157 158 159 |
# File 'lib/spidy/connector/lightpanda.rb', line 157 def try(*args) send(*args) if respond_to?(args.first) end |
#xpath ⇒ Object
149 150 151 |
# File 'lib/spidy/connector/lightpanda.rb', line 149 def xpath(*) @doc.xpath(*) end |