Class: Ethmo::Monitor

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ethmo/monitor.rb,
lib/ethmo/monitor/new_head.rb

Overview

:nodoc:

Defined Under Namespace

Classes: NewHead

Instance Method Summary collapse

Constructor Details

#initialize(type = 'newHeads') ⇒ Monitor

Returns a new instance of Monitor.



10
11
12
13
14
15
16
# File 'lib/ethmo/monitor.rb', line 10

def initialize(type = 'newHeads')
  @conn = IPCSocket.new(Config.socket)
  @type = type
  @thread = nil
  @stop = false
  @queue = Queue.new
end

Instance Method Details

#each(&_block) ⇒ Object



18
19
20
# File 'lib/ethmo/monitor.rb', line 18

def each(&_block)
  yield @queue.pop until stop?
end

#startObject



22
23
24
25
26
# File 'lib/ethmo/monitor.rb', line 22

def start
  return if @thread
  subscribe!
  @thread = Thread.new { process until stop? }
end

#stopObject



32
33
34
# File 'lib/ethmo/monitor.rb', line 32

def stop
  @stop = true
end

#stop?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/ethmo/monitor.rb', line 28

def stop?
  @stop == true
end