You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
772 B
Ruby
30 lines
772 B
Ruby
# frozen_string_literal: true
|
|
|
|
# SPDX-License-Identifier: MIT OR Apache-2.0
|
|
#
|
|
# Copyright (c) 2020 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
# Monkey-patch ruby-progressbar so that it supports reporting the progress in KiB instead of Byte.
|
|
|
|
class ProgressBar
|
|
# Add kibi version of progress
|
|
class Progress
|
|
def progress_kibi
|
|
@progress / 1024
|
|
end
|
|
end
|
|
|
|
module Format
|
|
# Add new formatting option
|
|
class Molecule
|
|
MOLECULES_EXTENDED = MOLECULES.dup
|
|
MOLECULES_EXTENDED[:k] = %i[progressable progress_kibi]
|
|
|
|
def initialize(letter)
|
|
self.key = letter
|
|
self.method_name = MOLECULES_EXTENDED.fetch(key.to_sym)
|
|
end
|
|
end
|
|
end
|
|
end
|