Class: Ubidots::Datasource

Inherits:
Object
  • Object
show all
Defined in:
lib/ubidots/datasource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Datasource

Returns a new instance of Datasource.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ubidots/datasource.rb', line 8

def initialize(data)
  @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"]
  @owner = data["owner"]
  @parent = data["parent"]
  @context = data["context"]
  @variables_url = data["variables_url"]
  @number_of_variables = data["number_of_variables"]
end

Instance Attribute Details

#context ⇒ Object (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/ubidots/datasource.rb', line 6

def context
  @context
end

#created_at ⇒ Object (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def created_at
  @created_at
end

#description ⇒ Object (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def description
  @description
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def id
  @id
end

#last_activity ⇒ Object (readonly)

Returns the value of attribute last_activity.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def last_activity
  @last_activity
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def name
  @name
end

#number_of_variables ⇒ Object (readonly)

Returns the value of attribute number_of_variables.



6
7
8
# File 'lib/ubidots/datasource.rb', line 6

def number_of_variables
  @number_of_variables
end

#owner ⇒ Object (readonly)

Returns the value of attribute owner.



6
7
8
# File 'lib/ubidots/datasource.rb', line 6

def owner
  @owner
end

#parent ⇒ Object (readonly)

Returns the value of attribute parent.



6
7
8
# File 'lib/ubidots/datasource.rb', line 6

def parent
  @parent
end

#tags ⇒ Object (readonly)

Returns the value of attribute tags.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def tags
  @tags
end

#url ⇒ Object (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/ubidots/datasource.rb', line 5

def url
  @url
end

#variables_url ⇒ Object (readonly)

Returns the value of attribute variables_url.



6
7
8
# File 'lib/ubidots/datasource.rb', line 6

def variables_url
  @variables_url
end

Instance Method Details

#get_variables ⇒ Object



23
24
25
26
27
28
# File 'lib/ubidots/datasource.rb', line 23

def get_variables
  endpoint = "datasources/#{@id}/variables"
  response = Ubidots::ApiClient::get endpoint
  raw_items = response["results"]
  return Ubidots::ApiClient::transform_to_variable_objects raw_items
end

#primary_key ⇒ Object



35
36
37
# File 'lib/ubidots/datasource.rb', line 35

def primary_key
  name
end

#variables ⇒ Object



31
32
33
# File 'lib/ubidots/datasource.rb', line 31

def variables
  VariableService.retrieve_for_datasource(self)
end