class Pretty::Bar

Overview

Pretty::Bar builds Ascii-art bar string for the #val and #max

bar = Pretty::Bar.new(val: 43, max: 176, width: 30)
bar.val   # => 43
bar.val_s # => " 43/176"
bar.max   # => 176
bar.width # => 30
bar.mark  # => "|"
bar.empty # => " "
bar.bar   # => "|||||||                       "
bar.pct   # => 24
bar.pct_s # => " 24%"
bar.to_s  # => "[|||||||                       ]  43/176 ( 24%)"

Defined in:

pretty/bar.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(val : Int32, max : Int32, width : Int32 = 68, mark : String = "|", empty : String = " ") #

[View source]

Instance Method Detail

def bar #

=> "||||||| "


[View source]
def empty : String #

[View source]
def mark : String #

[View source]
def max : Int32 #

[View source]
def pct : Int32 #

=> 24


[View source]
def pct_s : String #

=> " 24%"


[View source]
def to_s(io : IO) #

=> "[||||||| ] 43/176 (24%)"


[View source]
def val : Int32 #

[View source]
def val_s : String #

=> " 43/176"


[View source]
def width : Int32 #

[View source]