Class: Cherrypicker::Cherrypick

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Cherrypick.



7
8
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
34
35
# File 'lib/cherrypicker/cherrypick.rb', line 7

def initialize(link, opts={})
  o = {
    :location => nil, 
    :username  => nil,
    :password  => nil,
  }.merge(opts)

  @link         = link
  @username     = o[:username]
  @password     = o[:password]
  @directory    = o[:location]
  
  Dir[File.join(File.dirname(__FILE__),"../plugins/*.rb")].each do |plugin|
  	load plugin
  end
  
  plugins = ["Hotfile", "Megavideo", "Rapidshare", "Rghost", "Vimeo", "Youtube", "Googlevideo"]
  classname = URI.parse(@link.to_s).host[/[^www\.]+/].capitalize
  
  supported_host = plugins.include?(classname)
  
  if supported_host == true
    instance = Object.const_get('Cherrypicker').const_get("#{classname}")
    instance.new(@link, :location => @location, :username => @username, :password => @password).download
  else
    Cherrypicker::download_file(@link, :location => @location)
  end
  
end

Instance Attribute Details

Returns the value of attribute link.



5
6
7
# File 'lib/cherrypicker/cherrypick.rb', line 5

def link
  @link
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/cherrypicker/cherrypick.rb', line 5

def location
  @location
end

#passwordObject

Returns the value of attribute password.



5
6
7
# File 'lib/cherrypicker/cherrypick.rb', line 5

def password
  @password
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/cherrypicker/cherrypick.rb', line 5

def username
  @username
end