Class: Monitorer

Inherits:
Object
  • Object
show all
Defined in:
lib/monitorer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Monitorer

Returns a new instance of Monitorer.



33
34
35
36
# File 'lib/monitorer.rb', line 33

def initialize(opts={})
  @channel = EventMachine::Channel.new
  EventMachine.start_server opts[:host], opts[:port], MonitorConnection, self
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



23
24
25
# File 'lib/monitorer.rb', line 23

def channel
  @channel
end

Class Method Details

.notify(event) ⇒ Object



29
30
31
# File 'lib/monitorer.rb', line 29

def self.notify(event)
  current.notify(event) if current
end

.setup!(opts) ⇒ Object



25
26
27
# File 'lib/monitorer.rb', line 25

def self.setup!(opts)
  @@current = Monitorer.new(opts)
end

Instance Method Details

#notify(event) ⇒ Object



38
39
40
# File 'lib/monitorer.rb', line 38

def notify(event)
  @channel.push JSON.dump(event)
end