Class: Termplot::Producers::CommandProducer

Inherits:
BaseProducer show all
Defined in:
lib/termplot/producers/command_producer.rb

Instance Method Summary collapse

Methods inherited from BaseProducer

#close, #closed?, #initialize, #register_consumer, #shift

Constructor Details

This class inherits a constructor from Termplot::Producers::BaseProducer

Instance Method Details

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/termplot/producers/command_producer.rb', line 4

def run
  loop do
    n = `/bin/bash -c '#{options.command}'`.chomp
    # TODO: Error handling...

    if numeric?(n)
      queue << n.to_f
      consumer&.run
    end

    # Interval is in ms
    sleep(options.interval / 1000.0)
  end
end