Class: EmuPower::Types
- Inherits:
-
Object
- Object
- EmuPower::Types
- Defined in:
- lib/emu_power/types.rb
Overview
Notification types. Provides convenience calculators and accessors for the notifications sent by the EMU device.
Defined Under Namespace
Classes: ConnectionStatus, CurrentPeriodUsage, CurrentSummationDelivered, DeviceInfo, InstantaneousDemand, LastPeriodUsage, MessageCluster, MeterInfo, MeterList, NetworkInfo, Notification, PriceCluster, ProfileData, ScheduleInfo, TimeCluster
Class Method Summary collapse
-
.construct(data) ⇒ Object
Dispatch to the appropriate container class based on the type.
-
.notify_roots ⇒ Object
Helper to get the element names of all types.
Class Method Details
.construct(data) ⇒ Object
Dispatch to the appropriate container class based on the type. Expects a data hash. Returns nil on bad message.
128 129 130 131 132 133 134 135 136 |
# File 'lib/emu_power/types.rb', line 128 def self.construct(data) type = data['MessageType'] return nil if type == nil || !notify_roots.include?(type) klass = self.const_get(type) return klass.new(data) end |
.notify_roots ⇒ Object
Helper to get the element names of all types
139 140 141 |
# File 'lib/emu_power/types.rb', line 139 def self.notify_roots return Notification.subclasses.map(&:root_name) end |