Class: UPS
Constant Summary collapse
- ATTRS =
%i(input_amps output_amps battery_voltage charge)
Instance Attribute Summary collapse
-
#endpoint_uri ⇒ Object
Returns the value of attribute endpoint_uri.
Instance Method Summary collapse
-
#initialize(hostname = nil) ⇒ UPS
constructor
A new instance of UPS.
- #scrape_battery_voltage ⇒ Object
- #scrape_charge ⇒ Object
- #scrape_input_amps ⇒ Object
- #scrape_output_amps ⇒ Object
Methods included from Scrapable
Constructor Details
#initialize(hostname = nil) ⇒ UPS
Returns a new instance of UPS.
9 10 11 12 |
# File 'lib/liebert/ups.rb', line 9 def initialize(hostname = nil) @endpoint_uri = "http://#{hostname}/graphic/smallUps.htm" unless hostname.nil? create_getters end |
Instance Attribute Details
#endpoint_uri ⇒ Object
Returns the value of attribute endpoint_uri.
4 5 6 |
# File 'lib/liebert/ups.rb', line 4 def endpoint_uri @endpoint_uri end |
Instance Method Details
#scrape_battery_voltage ⇒ Object
22 23 24 |
# File 'lib/liebert/ups.rb', line 22 def scrape_battery_voltage @battery_voltage = @parsed_response.xpath('//*[@id="Battery"]/table/tr/td/center/table/tr[1]/td[2]').children.text.match(/(\d.*)/)[1].strip.to_f end |
#scrape_charge ⇒ Object
26 27 28 |
# File 'lib/liebert/ups.rb', line 26 def scrape_charge @charge = @parsed_response.xpath('//*[@id="Battery"]/table/tr/td/center/table/tr[3]/td[2]').children.text.match(/(\d.*)/)[1].strip.to_f end |
#scrape_input_amps ⇒ Object
14 15 16 |
# File 'lib/liebert/ups.rb', line 14 def scrape_input_amps @input_amps = @parsed_response.xpath('//*[@id="InputAmps"]/td[2]').children.text.match(/(\d.*)/)[1].strip.to_f end |
#scrape_output_amps ⇒ Object
18 19 20 |
# File 'lib/liebert/ups.rb', line 18 def scrape_output_amps @output_amps = @parsed_response.xpath('//*[@id="OutputAmps"]/td[2]').children.text.match(/(\d.*)/)[1].strip.to_f end |