Class: Rfam::Monitor
- Inherits:
-
Object
- Object
- Rfam::Monitor
- Defined in:
- lib/rfam/monitor.rb
Constant Summary collapse
- DEFAULT_INTERVAL =
1000
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#monitor ⇒ Object
readonly
Returns the value of attribute monitor.
-
#observer ⇒ Object
readonly
Returns the value of attribute observer.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path:, interval: nil) ⇒ Monitor
constructor
A new instance of Monitor.
- #run ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(path:, interval: nil) ⇒ Monitor
Returns a new instance of Monitor.
18 19 20 21 22 23 24 25 |
# File 'lib/rfam/monitor.rb', line 18 def initialize(path:, interval: nil) @path = path @interval = interval || DEFAULT_INTERVAL @listener = Listener.new @observer = Rfam::FileAlterationObserver.new(path) @observer.addListener(@listener) @monitor = Rfam::FileAlterationMonitor.new(@interval, @observer) end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
16 17 18 |
# File 'lib/rfam/monitor.rb', line 16 def interval @interval end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
16 17 18 |
# File 'lib/rfam/monitor.rb', line 16 def listener @listener end |
#monitor ⇒ Object (readonly)
Returns the value of attribute monitor.
16 17 18 |
# File 'lib/rfam/monitor.rb', line 16 def monitor @monitor end |
#observer ⇒ Object (readonly)
Returns the value of attribute observer.
16 17 18 |
# File 'lib/rfam/monitor.rb', line 16 def observer @observer end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/rfam/monitor.rb', line 16 def path @path end |
Class Method Details
.run(*args) ⇒ Object
12 13 14 |
# File 'lib/rfam/monitor.rb', line 12 def self.run(*args) new(*args).run end |
.start(*args) ⇒ Object
8 9 10 |
# File 'lib/rfam/monitor.rb', line 8 def self.start(*args) new(*args).start end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/rfam/monitor.rb', line 35 def run begin start sleep ensure stop end end |
#start ⇒ Object
27 28 29 |
# File 'lib/rfam/monitor.rb', line 27 def start monitor.start end |
#stop ⇒ Object
31 32 33 |
# File 'lib/rfam/monitor.rb', line 31 def stop monitor.stop(0) end |