class Progression
Constants
- VERSION
Attributes
count[R]
size[R]
Public Class Methods
new(count, current = 0)
click to toggle source
Accept proc, tick
# File lib/progression.rb, line 6 def initialize(count, current = 0) @count = count @current = current @current_inner_tick = 0 end
Public Instance Methods
tick()
click to toggle source
# File lib/progression.rb, line 12 def tick ticks_per_bump = Calculator.ticks_per_bump(window_size, count) if ticks_per_bump > 1 tick_more_elements_than_bars(ticks_per_bump) else tick_more_bars_than_elements(ticks_per_bump) end end
Private Instance Methods
bump_size()
click to toggle source
# File lib/progression.rb, line 44 def bump_size (window_size/count).to_i end
tick_character()
click to toggle source
# File lib/progression.rb, line 48 def tick_character '=' end
tick_more_bars_than_elements(ticks_per_bump)
click to toggle source
# File lib/progression.rb, line 34 def tick_more_bars_than_elements(ticks_per_bump) bump_size.times do print tick_character end end
tick_more_elements_than_bars(ticks_per_bump)
click to toggle source
# File lib/progression.rb, line 26 def tick_more_elements_than_bars(ticks_per_bump) if @current_inner_tick >= ticks_per_bump print tick_character @current_inner_tick = 0 end @current_inner_tick += 1 end
window_size()
click to toggle source
# File lib/progression.rb, line 40 def window_size @size ||= `tput cols`.strip.to_i end