Class: TinyProgressbar

Inherits:
Object
  • Object
show all
Defined in:
lib/tiny_progressbar.rb,
lib/tiny_progressbar/version.rb

Constant Summary collapse

CR =
"\r"
FORMAT =
'[%-30s] (%03d/%03d done)'
VERSION =
'0.0.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(goal) ⇒ TinyProgressbar

Returns a new instance of TinyProgressbar.



8
9
10
11
12
# File 'lib/tiny_progressbar.rb', line 8

def initialize(goal)
  @goal = goal
  @now = 0
  display
end

Instance Attribute Details

#goalObject (readonly)

Returns the value of attribute goal.



13
14
15
# File 'lib/tiny_progressbar.rb', line 13

def goal
  @goal
end

#nowObject (readonly)

Returns the value of attribute now.



13
14
15
# File 'lib/tiny_progressbar.rb', line 13

def now
  @now
end

Instance Method Details

#clearObject

進捗表示を消去する



22
23
24
# File 'lib/tiny_progressbar.rb', line 22

def clear
  print CR + ' ' * 100 + CR
end

#succeedObject



15
16
17
18
19
# File 'lib/tiny_progressbar.rb', line 15

def succeed
  @now += 1
  back_cursor
  display
end