README.md in helium-ruby-0.1.0 vs README.md in helium-ruby-0.2.0
- old
+ new
@@ -1,10 +1,11 @@
# helium-ruby
[![Build Status](https://travis-ci.org/helium/helium-ruby.svg?branch=master)](https://travis-ci.org/helium/helium-ruby)
[![Coverage Status](https://coveralls.io/repos/github/helium/helium-ruby/badge.svg?branch=master)](https://coveralls.io/github/helium/helium-ruby?branch=master)
[![Code Climate](https://codeclimate.com/github/helium/helium-ruby/badges/gpa.svg)](https://codeclimate.com/github/helium/helium-ruby)
+[![Gem Version](https://badge.fury.io/rb/helium-ruby.svg)](https://badge.fury.io/rb/helium-ruby)
A Ruby gem for building applications with the Helium API. [Helium](https://www.helium.com/) is an integrated platform of smart sensors, communication, edge and cloud compute that enables numerous sensing applications. For more information about the underlying REST API, check out [the Helium docs](https://docs.helium.com/).
## Installation
@@ -128,35 +129,59 @@
```ruby
sensor.timeseries(size: 10_000).length
# => 10000
```
-The data points are sorted from most recent, to least recent. The `.previous` method on a `Helium::Timeseries` object will return a new `Helium::Timeseries` object with the next page of Timeseries data:
+The data points are sorted from most recent, to least recent. The `.previous` method on a `Helium::Timeseries` object will return a new `Helium::Timeseries` object with the previous page of Timeseries data. Similarly, the `.next` method on a `Helium::Timeseries` object will return the next page of timeseries data, if it exists. If not, it will return `false`.
```ruby
timeseries = sensor.timeseries
# => #<Helium::Timeseries:0x007ff9e10d2c48 @data_points=[#<Helium::DataPoint:0x007ff9e10d2568 @id="3595e562-c065-442e-a3af-c6f43ddb1500", @timestamp="2016-08-10T13:21:49.866Z", @value=27, @port="l">, ...
-timeseries.previous
+previous_timeseries = timeseries.previous
# => #<Helium::Timeseries:0x007ff9dc141008 @data_points=[#<Helium::DataPoint:0x007ff9dc140f68 @id="1e4062cf-361d-415e-8c05-cd04954424d1", @timestamp="2016-08-10T13:11:49.353Z", @value=99804.15, @port="p">, ...
+
+previous_timeseries.next
+# =>
```
If no previous data exists, the `.previous` method will return `false`.
```ruby
sensor.timeseries.previous
# => false
```
+#### Timeseries Aggregations
+In addition to returning the raw data points, Helium can return timeseries data aggregated into buckets.
+
+
+For example, if you wanted to display a graph of a sensor's temperature min, max and average readings grouped by day, you could do the following:
+
+```ruby
+data_points = sensor.timeseries(port: 't', aggtype: 'min,max,avg', aggsize: '1d')
+# => #<Helium::Timeseries:0x007fe7038c2d18 @data_points=[#<Helium::DataPoint:0x007fe7038c2c00 @client=<Helium::Client @debug=true>, @id="a93e47f4-2fb2-4336-84c0-20f83ee2988e", @timestamp="2016-08-16T00:00:00Z", @value={"max"=>22.579952, "avg"=>22.1155383392857, "min"=>21.774511}, @port="agg(t)">, ...
+
+data_points.first.min
+# => 21.774511
+
+data_points.first.max
+# => 22.579952
+
+data_points.first.avg
+# => 22.1155383392857
+```
+
+
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
### Roadmap
-- [ ] Timeseries Aggregations
+- [X] Timeseries Aggregations
- [ ] POST/PUT/DELETE users, orgs, sensors, timeseries
- [ ] Ports
- [ ] Labels
- [ ] Elements