Class: Drophunter::Page

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

Constant Summary collapse

BASE_URL =
"http://d.pr/i/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



4
5
6
# File 'lib/drophunter/page.rb', line 4

def id
  @id
end

Instance Method Details

#save(something, saver) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/drophunter/page.rb', line 7

def save(something, saver)
  puts "Downloading #{url}"

  begin
    something.new(Nokogiri::HTML(open(url)), id).find_and_save(saver)
  rescue *error_messages.keys => error
    puts error_messages[error.class]
  end
end