Class: Circle::CLI::Watcher
- Inherits:
-
Object
- Object
- Circle::CLI::Watcher
- Defined in:
- lib/circle/cli/watcher.rb
Instance Attribute Summary collapse
-
#displayer ⇒ Object
readonly
Returns the value of attribute displayer.
-
#preloader ⇒ Object
readonly
Returns the value of attribute preloader.
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize(&displayer) ⇒ Watcher
constructor
A new instance of Watcher.
- #poll(polling_frequency) ⇒ Object
- #preload ⇒ Object
- #to_preload(&preloader) ⇒ Object
Constructor Details
#initialize(&displayer) ⇒ Watcher
Returns a new instance of Watcher.
6 7 8 9 |
# File 'lib/circle/cli/watcher.rb', line 6 def initialize(&displayer) @displayer = displayer @preloader = -> {} end |
Instance Attribute Details
#displayer ⇒ Object (readonly)
Returns the value of attribute displayer.
4 5 6 |
# File 'lib/circle/cli/watcher.rb', line 4 def displayer @displayer end |
#preloader ⇒ Object (readonly)
Returns the value of attribute preloader.
4 5 6 |
# File 'lib/circle/cli/watcher.rb', line 4 def preloader @preloader end |
Instance Method Details
#display ⇒ Object
19 20 21 |
# File 'lib/circle/cli/watcher.rb', line 19 def display displayer.call end |
#poll(polling_frequency) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/circle/cli/watcher.rb', line 23 def poll(polling_frequency) loop do display sleep polling_frequency preload clear end rescue Interrupt exit 0 end |
#preload ⇒ Object
15 16 17 |
# File 'lib/circle/cli/watcher.rb', line 15 def preload preloader.call end |
#to_preload(&preloader) ⇒ Object
11 12 13 |
# File 'lib/circle/cli/watcher.rb', line 11 def to_preload(&preloader) @preloader = preloader end |