Class: Ambient::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/ambient/device.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mac_address, info, last_data) ⇒ Device

Create a new Device instance

Parameters:

  • mac_address (String)

    the mac address of the device

  • info (Ambient::DeviceInfo)

    information about the device

  • last_data (Hash)

    the latest measurement data from the device


30
31
32
33
34
# File 'lib/ambient/device.rb', line 30

def initialize(mac_address, info, last_data)
  @mac_address = mac_address
  @info = info
  @last_data = last_data
end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.


18
19
20
# File 'lib/ambient/device.rb', line 18

def info
  @info
end

#last_dataObject (readonly)

Returns the value of attribute last_data.


18
19
20
# File 'lib/ambient/device.rb', line 18

def last_data
  @last_data
end

#mac_addressObject (readonly)

Returns the value of attribute mac_address.


18
19
20
# File 'lib/ambient/device.rb', line 18

def mac_address
  @mac_address
end

Class Method Details

.from_hash(data) ⇒ Object


20
21
22
# File 'lib/ambient/device.rb', line 20

def self.from_hash(data)
  Ambient::Device.new(data.dig("macAddress"), Ambient::DeviceInfo.from_hash(data.dig("info")), data.dig("lastData"))
end