class NeptuneApex::Status
Attributes
date[RW]
outlets[RW]
power[RW]
probes[RW]
Public Class Methods
from_xml(data)
click to toggle source
# File lib/neptune_apex/status.rb, line 8 def self.from_xml(data) status = Status.new status.read_xml(data) return status end
new()
click to toggle source
# File lib/neptune_apex/status.rb, line 15 def initialize @probes = {} @outlets = {} end
Public Instance Methods
add_outlet(name, id, state, device_id)
click to toggle source
# File lib/neptune_apex/status.rb, line 51 def add_outlet(name, id, state, device_id) @outlets[name] = { :id => id, :state => state, :device_id => device_id, } end
add_probe(name, value, type)
click to toggle source
# File lib/neptune_apex/status.rb, line 46 def add_probe(name, value, type) @probes[name] = { :value => BigDecimal.new(value), :type => type } end
read_xml(xml)
click to toggle source
# File lib/neptune_apex/status.rb, line 21 def read_xml(xml) doc = Nokogiri::XML(xml) @date = Date.strptime(doc.at_xpath('//status/date').text, '%m/%d/%Y %H:%M:%s') doc.xpath('//status/probes/probe').each{|probe| add_probe( probe.at_xpath('./name').text, probe.at_xpath('./value').text, probe.at_xpath('./type').text ) } doc.xpath('//status/outlets/outlet').each{|outlet| add_outlet( outlet.at_xpath('./name').text, outlet.at_xpath('./outputID').text, outlet.at_xpath('./state').text, outlet.at_xpath('./deviceID').text ) } end