Class: InteractiveLogger::Step
- Inherits:
-
Object
- Object
- InteractiveLogger::Step
- Defined in:
- lib/interactive_logger/step.rb
Constant Summary collapse
- PROGRESS_SYMBOLS =
%w(- \\ | /)
- FAILURE_SYMBOL =
'✗'.red
- SUCCESS_SYMBOL =
'✓'.green
- LB =
'['.light_black
- RB =
']'.light_black
Instance Method Summary collapse
-
#blank ⇒ Object
Blank out the current line.
- #continue(str = nil) ⇒ Object
- #failure(str = nil) ⇒ Object
-
#initialize(str, show_time: true) ⇒ Step
constructor
A new instance of Step.
- #repaint ⇒ Object
- #success(str = nil) ⇒ Object
Constructor Details
#initialize(str, show_time: true) ⇒ Step
Returns a new instance of Step.
10 11 12 13 14 15 16 |
# File 'lib/interactive_logger/step.rb', line 10 def initialize(str, show_time: true) @last_str = str @start = Time.now @show_time = show_time @pos = 0 print_msg(in_progress_prefix << str) end |
Instance Method Details
#blank ⇒ Object
Blank out the current line.
35 36 37 38 39 40 41 |
# File 'lib/interactive_logger/step.rb', line 35 def blank print "\r" if @last_print_msg print ' ' * @last_print_msg.uncolorize.size end print "\r" end |
#continue(str = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/interactive_logger/step.rb', line 18 def continue(str = nil) @pos += 1 @last_str = str if str print_msg(in_progress_prefix << @last_str) end |
#failure(str = nil) ⇒ Object
24 25 26 27 |
# File 'lib/interactive_logger/step.rb', line 24 def failure(str = nil) @last_str = str if str print_msg(prefix(FAILURE_SYMBOL) << @last_str) end |
#repaint ⇒ Object
43 44 45 |
# File 'lib/interactive_logger/step.rb', line 43 def repaint print @last_print_msg end |
#success(str = nil) ⇒ Object
29 30 31 32 |
# File 'lib/interactive_logger/step.rb', line 29 def success(str = nil) @last_str = str if str print_msg(prefix(SUCCESS_SYMBOL) << @last_str) end |