Class: Findi::Device

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Device

Returns a new instance of Device.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/findi/device.rb', line 5

def initialize(json)
  if location = json['location'] and location.is_a?(Hash)
    @location_timestamp = Time.at(location['timeStamp'] / 1000)
    @location_type = location['positionType']
    @horizontal_accuracy = location['horizontalAccuracy']
    @location_finished = location['locationFinished']
    @longitude = location['longitude']
    @latitude = location['latitude']
  end

  @is_locating = json['isLocating']
  @model = json['deviceModel']
  @status = json['deviceStatus']
  @id = json['id']
  @name = json['name']
  @kind = json['deviceClass']
  @battery_status = json['batteryStatus']
  @battery_level = json['batteryLevel']
end

Instance Attribute Details

#battery_levelObject (readonly)

Returns the value of attribute battery_level.



3
4
5
# File 'lib/findi/device.rb', line 3

def battery_level
  @battery_level
end

#battery_statusObject (readonly)

Returns the value of attribute battery_status.



3
4
5
# File 'lib/findi/device.rb', line 3

def battery_status
  @battery_status
end

#horizontal_accuracyObject (readonly)

Returns the value of attribute horizontal_accuracy.



3
4
5
# File 'lib/findi/device.rb', line 3

def horizontal_accuracy
  @horizontal_accuracy
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/findi/device.rb', line 3

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



3
4
5
# File 'lib/findi/device.rb', line 3

def kind
  @kind
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



3
4
5
# File 'lib/findi/device.rb', line 3

def latitude
  @latitude
end

#location_timestampObject (readonly)

Returns the value of attribute location_timestamp.



3
4
5
# File 'lib/findi/device.rb', line 3

def location_timestamp
  @location_timestamp
end

#location_typeObject (readonly)

Returns the value of attribute location_type.



3
4
5
# File 'lib/findi/device.rb', line 3

def location_type
  @location_type
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



3
4
5
# File 'lib/findi/device.rb', line 3

def longitude
  @longitude
end

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/findi/device.rb', line 3

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/findi/device.rb', line 3

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/findi/device.rb', line 3

def status
  @status
end

Instance Method Details

#is_locating?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/findi/device.rb', line 25

def is_locating?
  @is_locating
end

#location_finished?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/findi/device.rb', line 29

def location_finished?
  @location_finished
end