Class: Shutwork::Command::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Display
Defined in:
lib/shutwork/command/base.rb

Direct Known Subclasses

Help, Me, Rooms, Token

Instance Method Summary collapse

Methods included from Display

#display_account, #display_file, #display_message, #display_room, #format_datetime, #format_filesize, #to_filesize_human

Constructor Details

#initializeBase

Returns a new instance of Base.



16
17
18
# File 'lib/shutwork/command/base.rb', line 16

def initialize
  @shell = Thor::Shell::Color.new
end

Instance Method Details

#download_file(url, dst, at = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shutwork/command/base.rb', line 20

def download_file url, dst, at = nil
  FileUtils.mkdir_p dst.dirname
  open(url) do |i|
    open(dst, 'wb') do |o|
      o.write i.read
    end
    if at
      File.utime at, at, dst
    end
  end
end