Module: Hab::Formatter::Graph
- Included in:
- Hab::Formatter
- Defined in:
- lib/hab/formatter/graph.rb
Constant Summary collapse
- BAR_SIZE =
20
Instance Method Summary collapse
Instance Method Details
#bar(value, max, color) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/hab/formatter/graph.rb', line 9 def (value, max, color) percent = value.to_f / max.to_f blocks = (percent * BAR_SIZE).floor spaces = BAR_SIZE - blocks = ('■' * blocks).colorize(color) space = ' ' * spaces endpost = '|'.colorize(:light_black) "#{endpost}#{}#{space}#{endpost}" end |
#statbar(label, value, max) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/hab/formatter/graph.rb', line 19 def (label, value, max) description = label.to_s.ljust(7).colorize(stat_color(label)) chart = (value, max, stat_color(label)) of = "/#{max.to_i}".colorize(:light_black) numeric = "#{value.to_i}#{of}".rjust(10) "#{description} #{chart} #{numeric}" end |