Class: Captain::Remote::ProgressMeter

Inherits:
Object
  • Object
show all
Defined in:
lib/captain/remote.rb

Constant Summary collapse

MOVE_CURSOR_UP_1_LINE =

For these ANSI escape sequences and more, see en.wikipedia.org/wiki/ANSI_escape_code

"\e[1A"
ERASE_ENTIRE_LINE =
"\e[2K"
MOVE_CURSOR_TO_COLUMN_1 =

columns are 1-based, oddly enough

"\e[1G"
OVERWRITE_PREVIOUS_LINE =
"#{MOVE_CURSOR_UP_1_LINE}#{ERASE_ENTIRE_LINE}#{MOVE_CURSOR_TO_COLUMN_1}"

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ ProgressMeter

Returns a new instance of ProgressMeter.



164
165
166
167
# File 'lib/captain/remote.rb', line 164

def initialize(uri)
  puts uri
  puts
end

Instance Method Details

#the_currently_downloaded_size_is(size) ⇒ Object



177
178
179
180
# File 'lib/captain/remote.rb', line 177

def the_currently_downloaded_size_is(size)
  @current = size
  report
end

#the_total_size_is(size) ⇒ Object



173
174
175
# File 'lib/captain/remote.rb', line 173

def the_total_size_is(size)
  @total_size = size
end

#to_open_uri_hashObject



169
170
171
# File 'lib/captain/remote.rb', line 169

def to_open_uri_hash
  { :content_length_proc => method(:the_total_size_is), :progress_proc => method(:the_currently_downloaded_size_is) }
end