Class: PgVerify::Shell::LineAnimation
- Inherits:
-
LoadingAnimation
- Object
- LoadingAnimation
- PgVerify::Shell::LineAnimation
- Defined in:
- lib/pg-verify/shell/loading/line_animation.rb
Instance Attribute Summary
Attributes inherited from LoadingAnimation
#last_output_length, #loading_message, #start_time
Instance Method Summary collapse
- #format_line(string) ⇒ Object
-
#initialize(loading_message) ⇒ LineAnimation
constructor
A new instance of LineAnimation.
- #on_anim(passed_time) ⇒ Object
- #printl(string) ⇒ Object
Methods inherited from LoadingAnimation
#on_start, #on_stop, #print_anim, #start, #started?, #stop
Constructor Details
#initialize(loading_message) ⇒ LineAnimation
Returns a new instance of LineAnimation.
8 9 10 11 |
# File 'lib/pg-verify/shell/loading/line_animation.rb', line 8 def initialize() super() @last_line = nil end |
Instance Method Details
#format_line(string) ⇒ Object
29 30 31 32 |
# File 'lib/pg-verify/shell/loading/line_animation.rb', line 29 def format_line(string) return () if string.blank? "#{()} [ #{string} ]" end |
#on_anim(passed_time) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/pg-verify/shell/loading/line_animation.rb', line 13 def on_anim(passed_time) color = (passed_time * 2).to_i % 2 == 0 ? :loading : :white circle = (passed_time * 2).to_i % 2 == 0 ? "▶" : "-" circle = circle.color(color) " #{circle} #{string = format_line(@last_line)} " end |
#printl(string) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/pg-verify/shell/loading/line_animation.rb', line 20 def printl(string) return unless started?() string = string.to_s string = (string ||= "").gsub("\n", '') string = string.c_sidenote unless Colorizer.color?(string) @last_line = string # print_anim(string) end |