Class: RakeUp::Utilities::PortCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/rakeup/utilities/port_check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ PortCheck

Returns a new instance of PortCheck.



9
10
11
12
# File 'lib/rakeup/utilities/port_check.rb', line 9

def initialize(host, port)
  @host = host
  @port = port
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/rakeup/utilities/port_check.rb', line 7

def error
  @error
end

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/rakeup/utilities/port_check.rb', line 7

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/rakeup/utilities/port_check.rb', line 7

def port
  @port
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rakeup/utilities/port_check.rb', line 18

def closed?
  @status == false
end

#open?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rakeup/utilities/port_check.rb', line 14

def open?
  @status == true
end

#runObject



22
23
24
# File 'lib/rakeup/utilities/port_check.rb', line 22

def run
  @status = run_check
end

#to_sObject



26
27
28
29
30
31
32
# File 'lib/rakeup/utilities/port_check.rb', line 26

def to_s
  if open?
    "Found process listening on #{host}:#{port}"
  else
    "Unable to connect to process on #{host}:#{port}: #{error}"
  end
end