Class: Cherrypicker::Rghost
- Inherits:
-
Object
- Object
- Cherrypicker::Rghost
- Defined in:
- lib/cherrypicker/plugins/rghost.rb
Instance Attribute Summary collapse
-
#download_url ⇒ Object
Returns the value of attribute download_url.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#link ⇒ Object
Returns the value of attribute link.
-
#location ⇒ Object
Returns the value of attribute location.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(link, opts = {}) ⇒ Rghost
constructor
A new instance of Rghost.
Constructor Details
#initialize(link, opts = {}) ⇒ Rghost
Returns a new instance of Rghost.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cherrypicker/plugins/rghost.rb', line 9 def initialize(link, opts={}) o = { :location => nil, }.merge(opts) @link = link @filename = "" @location = o[:location] @download_url = "" #the rghost ID consists of decimal numbers in the URL rghost_id = @link[/\d+/] response = Cherrypicker::remote_query("http://rghost.net/#{rghost_id}") @filename = response.body[/<title>(.*\.[a-zA-Z]*).*RGhost/, 1] download_url = URI.encode(response.body[/<a href="(.*)" class=\"(file_link|download_link)\"/, 1]) reply = Cherrypicker::remote_query("#{download_url}") if reply.response['location'] @download_url = reply.response['location'] else @download_url = download_url end end |
Instance Attribute Details
#download_url ⇒ Object
Returns the value of attribute download_url.
7 8 9 |
# File 'lib/cherrypicker/plugins/rghost.rb', line 7 def download_url @download_url end |
#filename ⇒ Object
Returns the value of attribute filename.
7 8 9 |
# File 'lib/cherrypicker/plugins/rghost.rb', line 7 def filename @filename end |
#link ⇒ Object
Returns the value of attribute link.
7 8 9 |
# File 'lib/cherrypicker/plugins/rghost.rb', line 7 def link @link end |
#location ⇒ Object
Returns the value of attribute location.
7 8 9 |
# File 'lib/cherrypicker/plugins/rghost.rb', line 7 def location @location end |
Instance Method Details
#download ⇒ Object
35 36 37 |
# File 'lib/cherrypicker/plugins/rghost.rb', line 35 def download Cherrypicker::download_file(@download_url, :location => @location) end |