Class: Cherrypicker::Cherrypick
- Inherits:
-
Object
- Object
- Cherrypicker::Cherrypick
- Defined in:
- lib/cherrypicker/cherrypick.rb
Instance Attribute Summary collapse
-
#link ⇒ Object
Returns the value of attribute link.
-
#location ⇒ Object
Returns the value of attribute location.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(link, opts = {}) ⇒ Cherrypick
constructor
A new instance of Cherrypick.
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
#link ⇒ Object
Returns the value of attribute link.
5 6 7 |
# File 'lib/cherrypicker/cherrypick.rb', line 5 def link @link end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/cherrypicker/cherrypick.rb', line 5 def location @location end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/cherrypicker/cherrypick.rb', line 5 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/cherrypicker/cherrypick.rb', line 5 def username @username end |