Class: ServerStatus::Host
- Inherits:
-
Object
- Object
- ServerStatus::Host
- Defined in:
- lib/server-status/host.rb
Defined Under Namespace
Classes: RemoteCommandFailure
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #fetch_status(status_command) ⇒ Object
- #feteched_status? ⇒ Boolean
-
#initialize(config, name, host) ⇒ Host
constructor
A new instance of Host.
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
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/server-status/host.rb', line 5 def name @name end |
#status ⇒ Object
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..zip(raw_statuses).to_h @feteched_status = true @status = raw_statuses rescue RemoteCommandFailure => ex @status = { error: ex. } end |
#feteched_status? ⇒ Boolean
16 17 18 |
# File 'lib/server-status/host.rb', line 16 def feteched_status? @feteched_status end |