Class: ChambaSearchMx::HTMLPage

Inherits:
Object
  • Object
show all
Defined in:
lib/chamba_search_mx/html_page.rb

Overview

loads web page using nokogiri

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ HTMLPage

Returns a new instance of HTMLPage.

Parameters:

  • options (hash)

See Also:



12
13
14
# File 'lib/chamba_search_mx/html_page.rb', line 12

def initialize(opts = {})
  @base_url = opts[:base_url] || ChambaSearchMx::BASE_URL
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/chamba_search_mx/html_page.rb', line 8

def content
  @content
end

Instance Method Details

#load(url) ⇒ Object

loads Kokogiri::HTML:Document as @content which can be read

Parameters:

  • (string)


19
20
21
# File 'lib/chamba_search_mx/html_page.rb', line 19

def load(url)
  @content = Nokogiri::HTML open("#{@base_url}#{url}")
end