Class: Finch::Pinger

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/finch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Pinger

Returns a new instance of Pinger.



28
29
30
31
32
33
34
35
# File 'lib/finch.rb', line 28

def initialize(name, opts = {})
  @name = name
  @host = opts.fetch(:host, "localhost")
  @group = opts.fetch(:group, "Default")
  @port = opts.fetch(:port, lambda { raise(ArgumentError) })
  @timer  = every(opts.fetch(:frequency, 30)) { ping }
  async.ping
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



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

def group
  @group
end

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#last_successObject

Returns the value of attribute last_success.



26
27
28
# File 'lib/finch.rb', line 26

def last_success
  @last_success
end

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/finch.rb', line 26

def name
  @name
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#stateObject

Returns the value of attribute state.



26
27
28
# File 'lib/finch.rb', line 26

def state
  @state
end

#timerObject (readonly)

Returns the value of attribute timer.



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

def timer
  @timer
end

Instance Method Details

#pingObject



37
38
39
# File 'lib/finch.rb', line 37

def ping
  ping_accessor.ping ? success : error
end