Class: Omelete::Client

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

Constant Summary collapse

HOME_URL =
"http://omelete.uol.com.br/filmes-em-cartaz/"

Instance Method Summary collapse

Instance Method Details

#page_doc(complement) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/omelete.rb', line 24

def page_doc(complement)
  begin
    uri = URI.escape(HOME_URL + complement)
    @page_doc = Nokogiri::HTML(open(uri))
  rescue => e
    case e
    when OpenURI::HTTPError
      p "OpenURI::HTTPError on: #{HOME_URL + complement}"
    when SocketError
      p "SocketError on: #{HOME_URL + complement}"
    end
    @page_doc = nil
  rescue SystemCallError => e
    if e === Errno::ECONNRESET
      p "SystemCallError on: #{HOME_URL + complement}"
    end
    @page_doc = nil
  end
  @page_doc
end