Class: Nagios::API::Hosts
- Inherits:
-
Object
- Object
- Nagios::API::Hosts
- Defined in:
- lib/nagios/api/host.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
Instance Method Summary collapse
- #find(hostname) ⇒ Object
-
#initialize(args = {}) ⇒ Hosts
constructor
A new instance of Hosts.
- #reload ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Hosts
Returns a new instance of Hosts.
5 6 7 8 |
# File 'lib/nagios/api/host.rb', line 5 def initialize(args = {}) @api_client = args[:api_client] @host_cache = {} end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
3 4 5 |
# File 'lib/nagios/api/host.rb', line 3 def api_client @api_client end |
Instance Method Details
#find(hostname) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/nagios/api/host.rb', line 10 def find(hostname) return @host_cache[hostname] if @host_cache.has_key?(hostname) host = Host.new(api_client.api.query("/host/#{hostname}").merge(api_client: api_client)) @host_cache[hostname] = host host end |
#reload ⇒ Object
18 19 20 |
# File 'lib/nagios/api/host.rb', line 18 def reload @host_cache = {} end |