Class: R3Status::StatusLine
- Inherits:
-
Object
- Object
- R3Status::StatusLine
- Defined in:
- lib/r3status.rb
Overview
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
A list blocks to display, right to left, in the bar.
-
#postfix ⇒ Object
An object (e.g. String)that will be inserted at the ebd of a block’s text.
-
#prefix ⇒ Object
An object (e.g. String) that will be inserted at the start of a block’s text.
-
#update_interval ⇒ Object
The time (in seconds) between iterations.
Instance Method Summary collapse
-
#<<(block) ⇒ Object
Appends a new block to this StatusLine object.
-
#initialize(prefix: " ", postfix: nil, update_interval: 0.4) ⇒ StatusLine
constructor
Creates a new StatusLine object.
-
#run ⇒ Object
Starts the operation of the status line and the output of the data to the standard output.
Constructor Details
#initialize(prefix: " ", postfix: nil, update_interval: 0.4) ⇒ StatusLine
Creates a new StatusLine object.
39 40 41 42 43 44 |
# File 'lib/r3status.rb', line 39 def initialize(prefix: " ", postfix: nil, update_interval: 0.4) @blocks = [] @prefix = prefix @postfix = postfix @update_interval = update_interval end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
A list blocks to display, right to left, in the bar.
30 31 32 |
# File 'lib/r3status.rb', line 30 def blocks @blocks end |
#postfix ⇒ Object
An object (e.g. String)that will be inserted at the ebd of a block’s text. Default: nil.
34 35 36 |
# File 'lib/r3status.rb', line 34 def postfix @postfix end |
#prefix ⇒ Object
An object (e.g. String) that will be inserted at the start of a block’s text. Default: _“ ”_.
32 33 34 |
# File 'lib/r3status.rb', line 32 def prefix @prefix end |
#update_interval ⇒ Object
The time (in seconds) between iterations. Default: 0.4.
36 37 38 |
# File 'lib/r3status.rb', line 36 def update_interval @update_interval end |
Instance Method Details
#<<(block) ⇒ Object
Appends a new block to this StatusLine object.
47 48 49 |
# File 'lib/r3status.rb', line 47 def << block @blocks << block end |
#run ⇒ Object
Starts the operation of the status line and the output of the data to the standard output.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/r3status.rb', line 52 def run @reader_thread = Thread.new do loop do s = gets.chomp parse s end end @reader_thread.run at_exit do @reader_thread.kill @blocks.each { |b| b.terminate } end puts "{\"version\":1, \"click_events\":true}[" loop_with_interval(0.2) do @blocks.each {|b| b.update } puts "[#{transmission}]," end end |