class Ubidots::Variable
Attributes
created_at[R]
description[R]
icon[R]
id[R]
last_activity[R]
last_value[R]
name[R]
properties[R]
raw_datasource[R]
unit[R]
url[R]
values_url[R]
Public Class Methods
new(bridge, data)
click to toggle source
# File lib/ubidots/variable.rb, line 7 def initialize(bridge, data) @bridge = bridge @id = data["id"] @name = data["name"] @url = data["url"] @last_activity = data["last_activity"] @tags = data["tags"] @description = data["description"] @created_at = data["created_at"] @icon = data["icon"] @unit = data["unit"] @raw_datasource = data["datasource"] @properties = data["properties"] @values_url = data["values_url"] @last_value = data["last_value"] end
Public Instance Methods
get_datasource()
click to toggle source
# File lib/ubidots/variable.rb, line 48 def get_datasource if !@datasource datasource_id = @raw_datasource["id"] endpoint = "datasources/#{datasource_id}" response = @bridge.get endpoint @datasource = Ubidots::Datasource.new(@bridge, response) end return @datasource end
get_values()
click to toggle source
# File lib/ubidots/variable.rb, line 24 def get_values endpoint = "variables/#{@id}/values" response = @bridge.get endpoint return response["results"] end
remove_variable()
click to toggle source
# File lib/ubidots/variable.rb, line 43 def remove_variable endpoint = "variables/#{@id}" return @bridge.delete endpoint end
save_value(data)
click to toggle source
# File lib/ubidots/variable.rb, line 30 def save_value(data) endpoint = "variables/#{@id}/values" return @bridge.post endpoint, data end
save_values(data, force=false)
click to toggle source
# File lib/ubidots/variable.rb, line 35 def save_values(data, force=false) endpoint = "variables/#{@id}/values" if force == true endpoint = "#{endpoint}?force=true" end return @bridge.post endpoint, data end