Class: ServerStatus::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/server-status/host.rb

Defined Under Namespace

Classes: RemoteCommandFailure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name, host) ⇒ Host

Returns a new instance of Host.



8
9
10
11
12
13
14
# File 'lib/server-status/host.rb', line 8

def initialize(config, name, host)
  @config = config
  @name   = name
  @host   = host

  @feteched_status = false
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/server-status/host.rb', line 5

def name
  @name
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/server-status/host.rb', line 5

def status
  @status
end

Instance Method Details

#fetch_status(status_command) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/server-status/host.rb', line 20

def fetch_status(status_command)
  # Fetch statuses
  raw_statuses = execute_command(status_command)

  # Hashed statuses
  raw_statuses = raw_statuses.split(ServerStatus::StatusCommand::SEPARATOR)
  raw_statuses = raw_statuses.map(&:strip)
  raw_statuses = status_command.requested_options.zip(raw_statuses).to_h

  @feteched_status = true

  @status = raw_statuses


rescue RemoteCommandFailure => ex
  @status = { error: ex.message }
end

#feteched_status?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/server-status/host.rb', line 16

def feteched_status?
  @feteched_status
end