Class: Putsplus::Footer
- Inherits:
-
Object
- Object
- Putsplus::Footer
- Defined in:
- lib/putsplus/footer.rb
Overview
Sticks text to last line in console
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(text = "") ⇒ Footer
constructor
A new instance of Footer.
- #kill ⇒ Object
- #sticky_footer(text) ⇒ Object
Constructor Details
#initialize(text = "") ⇒ Footer
9 10 11 12 13 14 15 16 |
# File 'lib/putsplus/footer.rb', line 9 def initialize(text = "") @text = text @thread = Thread.new { while true do @text end } end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/putsplus/footer.rb', line 7 def text @text end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
6 7 8 |
# File 'lib/putsplus/footer.rb', line 6 def thread @thread end |
Instance Method Details
#alive? ⇒ Boolean
29 30 31 |
# File 'lib/putsplus/footer.rb', line 29 def alive? @thread.alive? end |
#kill ⇒ Object
18 19 20 21 22 |
# File 'lib/putsplus/footer.rb', line 18 def kill print " " * `tput cols`.to_i $stdout.flush Thread.kill(@thread) end |
#sticky_footer(text) ⇒ Object
24 25 26 27 |
# File 'lib/putsplus/footer.rb', line 24 def text print text.to_s + "\r" $stdout.flush end |