Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/term/process_bar.rb
Overview
Instance Method Summary collapse
-
#process_bar(width = IO.width - 8) ⇒ String
get process bar.
Instance Method Details
#process_bar(width = IO.width - 8) ⇒ String
get process bar.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/term/process_bar.rb', line 13 def (width = IO.width - 8) percent = format(' %3d%', self) line = '-' * width if self <= 0 "[#{line.insert(0, '🛫')}]#{percent}" elsif self >= 100 "[#{line.insert(-1, '🛬')}]#{percent}" else "[#{line.insert((self / 100.0 * width).to_i, '✈️')}]#{percent}" end end |