class Dapp::Downloader::BytesCount

Attributes

bytes[R]
total_bytes_count[R]

Public Class Methods

new(bytes, total_bytes_count: nil) click to toggle source
# File lib/dapp/downloader.rb, line 11
def initialize(bytes, total_bytes_count: nil)
  @bytes = bytes.to_f
  @total_bytes_count = total_bytes_count
end

Public Instance Methods

method_missing(method, *args, &blk) click to toggle source
# File lib/dapp/downloader.rb, line 45
def method_missing(method, *args, &blk)
  case method
  when :to_f, :to_i
    @bytes.send(method, *args, &blk)
  else
    raise
  end
end
to_s(*a) click to toggle source
# File lib/dapp/downloader.rb, line 16
def to_s(*a)
  max_bytes = @total_bytes_count || self
  width = sprintf("%.2f", max_bytes.bytes/1024/1024).bytesize
  sprintf("%#{width}.2f", @bytes/1024/1024)
end