Class: Spidy::Connector::Lightpanda::LightpandaPage

Inherits:
Object
  • Object
show all
Defined in:
lib/spidy/connector/lightpanda.rb

Overview

Page-like object that mimics the Mechanize::Page interface

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



125
126
127
# File 'lib/spidy/connector/lightpanda.rb', line 125

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



125
126
127
# File 'lib/spidy/connector/lightpanda.rb', line 125

def code
  @code
end

#response_codeObject (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

#titleObject (readonly)

Returns the value of attribute title.



125
126
127
# File 'lib/spidy/connector/lightpanda.rb', line 125

def title
  @title
end

#uriObject (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

#atObject



141
142
143
# File 'lib/spidy/connector/lightpanda.rb', line 141

def at(*)
  @doc.at(*)
end

#cssObject



145
146
147
# File 'lib/spidy/connector/lightpanda.rb', line 145

def css(*)
  @doc.css(*)
end

#encodingObject



153
154
155
# File 'lib/spidy/connector/lightpanda.rb', line 153

def encoding
  @doc.encoding
end

#searchObject

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

#xpathObject



149
150
151
# File 'lib/spidy/connector/lightpanda.rb', line 149

def xpath(*)
  @doc.xpath(*)
end