Class: Sphyg::Pulse
- Inherits:
-
Object
- Object
- Sphyg::Pulse
- Defined in:
- lib/sphyg/pulse.rb
Overview
Handles threading and running the throbber
Instance Method Summary collapse
-
#initialize(message, options = {}) ⇒ Pulse
constructor
A new instance of Pulse.
- #run(&blk) ⇒ Object
Constructor Details
#initialize(message, options = {}) ⇒ Pulse
Returns a new instance of Pulse.
6 7 8 9 |
# File 'lib/sphyg/pulse.rb', line 6 def initialize(, = {}) @message = @options = () end |
Instance Method Details
#run(&blk) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sphyg/pulse.rb', line 11 def run(&blk) # Note: the block will continue to run even if our throbber crashed. This # is more user-frindly than setting `abort_on_exception` for our thread. # TODO: use `Thread#reporting_on_exception` for Ruby versions >= 2.4 thr = ::Thread.new { throbber.run } yield blk ensure thr.kill print "\n" end |