Class: TempoIQ::BulkWrite

Inherits:
Object
  • Object
show all
Defined in:
lib/tempoiq/models/bulk_write.rb

Overview

Used to write DataPoints into your TempoIQ backend.

Instance Method Summary collapse

Constructor Details

#initializeBulkWrite

Returns a new instance of BulkWrite.



4
5
6
7
8
9
10
# File 'lib/tempoiq/models/bulk_write.rb', line 4

def initialize
  @writes = Hash.new do |sensors, device_key|
    sensors[device_key] = Hash.new do |points, sensor_key|
      points[sensor_key] = []
    end
  end
end

Instance Method Details

#<<(device_key, sensor_key, datapoint) ⇒ Object

Alias for #add



13
14
15
# File 'lib/tempoiq/models/bulk_write.rb', line 13

def <<(device_key, sensor_key, datapoint)
  add(device_key, sensor_key, datapoint)
end

#add(device_key, sensor_key, datapoint) ⇒ Object

Add a DataPoint to the request

  • device_key [String] - The device key to write to

  • sensor_key [String] - The sensor key within the device to write to

  • datapoint [DataPoint] - The datapoint to write



22
23
24
# File 'lib/tempoiq/models/bulk_write.rb', line 22

def add(device_key, sensor_key, datapoint)
  @writes[device_key][sensor_key] << datapoint.to_hash
end

#to_hashObject



26
27
28
# File 'lib/tempoiq/models/bulk_write.rb', line 26

def to_hash
  @writes
end