Class: ROM::InfluxDB::Dataset

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/influxdb/dataset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, connection) ⇒ Dataset

Returns a new instance of Dataset.



8
9
10
11
# File 'lib/rom/influxdb/dataset.rb', line 8

def initialize(name, connection)
  @name = name.to_s
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/rom/influxdb/dataset.rb', line 6

def connection
  @connection
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rom/influxdb/dataset.rb', line 6

def name
  @name
end

Instance Method Details

#each(&block) ⇒ Object



13
14
15
# File 'lib/rom/influxdb/dataset.rb', line 13

def each(&block)
  with_set { |set| set.each(&block) }
end

#insert(object) ⇒ Object Also known as: <<



17
18
19
# File 'lib/rom/influxdb/dataset.rb', line 17

def insert(object)
  connection.write_point(name, object)
end

#query(what = '*') ⇒ Object



26
27
28
# File 'lib/rom/influxdb/dataset.rb', line 26

def query(what = '*')
  connection.query("SELECT #{what} FROM #{name}")[name]
end

#where(query) ⇒ Object



22
23
24
# File 'lib/rom/influxdb/dataset.rb', line 22

def where(query)
  connection.query("SELECT * FROM #{name} WHERE #{query}")[name]
end