Sha256: efbb853d4f7a9ce717dd0609a4090ea75ddf3dc0f102e3396e462fbad1943b36
Contents?: true
Size: 743 Bytes
Versions: 2
Compression:
Stored size: 743 Bytes
Contents
module DeviceMap module DeviceData class Devices class DeviceNotFound < StandardError; end def self.parse(devices_xml) devices_doc = Nokogiri::XML(devices_xml) devices = devices_doc.xpath('//device').map do |device_node| Device.parse(device_node) end new(devices) end def initialize(devices) @device_index = devices.each_with_object({}) do |device, device_index| device_index[device.id] = device end end def find(device_id) # TODO: Return copy of <tt>Device</tt> object @device_index.fetch(device_id) do fail DeviceNotFound, "Cound not find device: #{device_id}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
device_map-0.1.1 | lib/device_map/device_data/devices.rb |
device_map-0.1.0 | lib/device_map/device_data/devices.rb |