Method: CurrentCost::Meter#update

Defined in:
lib/currentcost/meter.rb

#update(message) ⇒ Object

Internal use only, client code does not need to use this function. Informs the Meter object that a new message has been received by the serial port.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/currentcost/meter.rb', line 51

def update(message)
  unless message.nil?
    # Parse reading from message
    @latest_reading = Reading.from_xml(message)
    # Inform observers
    changed
    notify_observers(@latest_reading)
  end
rescue CurrentCost::ParseError
  nil
end