Class: Cherrypicker::Rghost

Inherits:
PluginBase show all
Defined in:
lib/cherrypicker/plugins/rghost.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PluginBase

inherited

Constructor Details

#initialize(link, opts = {}) ⇒ Rghost

Returns a new instance of Rghost.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cherrypicker/plugins/rghost.rb', line 13

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_urlObject

Returns the value of attribute download_url.



7
8
9
# File 'lib/cherrypicker/plugins/rghost.rb', line 7

def download_url
  @download_url
end

#filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/cherrypicker/plugins/rghost.rb', line 7

def filename
  @filename
end

Returns the value of attribute link.



7
8
9
# File 'lib/cherrypicker/plugins/rghost.rb', line 7

def link
  @link
end

#locationObject

Returns the value of attribute location.



7
8
9
# File 'lib/cherrypicker/plugins/rghost.rb', line 7

def location
  @location
end

Class Method Details

.matches_provider?(url) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/cherrypicker/plugins/rghost.rb', line 9

def self.matches_provider?(url)
  url.include?("rghost.com")
end

Instance Method Details

#downloadObject



39
40
41
# File 'lib/cherrypicker/plugins/rghost.rb', line 39

def download
  Cherrypicker::download_file(@download_url, :location => @location)
end