class Portfinder::Monitor

Portfinder scanner monitor

Attributes

host[RW]
port[RW]
state[R]
threads[RW]

Public Class Methods

new(state = :init) click to toggle source
   # File lib/portfinder/monitor.rb
 9 def initialize state = :init
10   self.state = state
11   @host = ""
12   @port = nil
13   @threads = 1
14 end

Public Instance Methods

start() click to toggle source
   # File lib/portfinder/monitor.rb
25 def start
26   self.state = :run
27   reset
28 end
state=(value) click to toggle source

Refactor: Enum?

   # File lib/portfinder/monitor.rb
17 def state= value
18   states = %i[init run term]
19   unless states.include?(value)
20     raise TypeError, "state can be any of #{states}"
21   end
22   @state = value
23 end
stop() click to toggle source
   # File lib/portfinder/monitor.rb
30 def stop
31   self.state = :term
32   reset
33 end
update(host, port) click to toggle source
   # File lib/portfinder/monitor.rb
35 def update host, port
36   @host = host
37   @port = port
38 end

Private Instance Methods

reset() click to toggle source
   # File lib/portfinder/monitor.rb
42 def reset
43   @host = ""
44   @port = nil
45   @threads = 1
46 end