Class: ROM::InfluxDB::Dataset
- Inherits:
-
Object
- Object
- ROM::InfluxDB::Dataset
- Defined in:
- lib/rom/influxdb/dataset.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(name, connection) ⇒ Dataset
constructor
A new instance of Dataset.
- #insert(object) ⇒ Object (also: #<<)
- #query(what = '*') ⇒ Object
- #where(query) ⇒ Object
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
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/rom/influxdb/dataset.rb', line 6 def connection @connection end |
#name ⇒ Object (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 |