Method: Particle::Device#initialize

Defined in:
lib/particle/device.rb

#initialize(client, attributes) ⇒ Device

Returns a new instance of Device.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/particle/device.rb', line 11

def initialize(client, attributes)
  super(client, attributes)

  if attributes.is_a? String
    if attributes =~ ID_REGEX
      @attributes = { id: attributes }
    else
      @attributes = { name: attributes }
    end
  else
    # Listing all devices returns partial attributes so check if the
    # device was fully loaded or not
    @fully_loaded = true if attributes.key?(:variables)
  end
end