Class: Infopark::UserIO::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/infopark/user_io.rb

Instance Method Summary collapse

Constructor Details

#initialize(label, user_io) ⇒ Progress

Returns a new instance of Progress.



16
17
18
19
# File 'lib/infopark/user_io.rb', line 16

def initialize(label, user_io)
  @label = label
  @user_io = user_io
end

Instance Method Details

#finishObject



33
34
35
36
37
38
# File 'lib/infopark/user_io.rb', line 33

def finish
  if @started
    user_io.tell("", newline: false)
    user_io.tell("OK", color: :green, bright: true)
  end
end

#incrementObject



28
29
30
31
# File 'lib/infopark/user_io.rb', line 28

def increment
  raise ImplementationError, "progress not started yet" unless @started
  user_io.tell(".", newline: false)
end

#startObject



21
22
23
24
25
26
# File 'lib/infopark/user_io.rb', line 21

def start
  unless @started
    user_io.tell("#{label} ", newline: false)
    @started = true
  end
end