Class: Downcer::CLI
- Inherits:
-
Object
- Object
- Downcer::CLI
- Defined in:
- lib/downcer/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(url) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(url) ⇒ CLI
Returns a new instance of CLI.
12 13 14 15 16 17 18 19 |
# File 'lib/downcer/cli.rb', line 12 def initialize(url) @url = URI.parse(URI.encode(url)) @config = get_config(@url) rescue NoMethodError, URI::InvalidURIError => e abort 'Usage: downcer <url>' rescue SystemCallError => e abort e.to_s end |
Class Method Details
.start(*args) ⇒ Object
8 9 10 |
# File 'lib/downcer/cli.rb', line 8 def self.start(*args) self.new(args.first).download end |
Instance Method Details
#download ⇒ Object
21 22 23 24 25 |
# File 'lib/downcer/cli.rb', line 21 def download puts "Use `#{@config['command']}`" puts '--' exec "#{@config['command']} #{@config['option']} '#{@url}'" end |