Class: Autoweb::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/autoweb/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, hash) ⇒ Parser

Returns a new instance of Parser.



87
88
89
90
91
92
93
94
# File 'lib/autoweb/page.rb', line 87

def initialize(page, hash)
  @page = page
  if hash.is_a?(String) 
    @url = hash
  else
    @url = page.url(hash)
  end
end

Instance Attribute Details

#pageObject

Returns the value of attribute page.



86
87
88
# File 'lib/autoweb/page.rb', line 86

def page
  @page
end

#urlObject

Returns the value of attribute url.



86
87
88
# File 'lib/autoweb/page.rb', line 86

def url
  @url
end

Instance Method Details

#[](key) ⇒ Object



101
102
103
# File 'lib/autoweb/page.rb', line 101

def [](key)
  contaent_parser[key]
end

#contaent_parserObject



105
106
107
# File 'lib/autoweb/page.rb', line 105

def contaent_parser
  @content_parser||=ContentParser.new(doc,page)
end

#docObject



109
110
111
# File 'lib/autoweb/page.rb', line 109

def doc
  @doc||=Hpricot(open(URI.encode url))
end

#goObject



96
97
98
99
# File 'lib/autoweb/page.rb', line 96

def go
  contaent_parser
  self
end