Skip to content

Instantly share code, notes, and snippets.

@calderonroberto
Created July 29, 2015 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calderonroberto/2b8a05825d2c6f17d7fa to your computer and use it in GitHub Desktop.
Save calderonroberto/2b8a05825d2c6f17d7fa to your computer and use it in GitHub Desktop.
Example using the stsplatform ruby library.
# Require the stsplatform gem. Make sure to install it
# To install from source run: "bundle exec rake install"
# to install from RubyGems run : "gem install stsplatform"
require 'stsplatform'
# A sensor to use for this example. We will use
SENSOR_NAME = 'calderonroberto.demo'
# First, create a client that will handle all the REST calls
c = STSPlatform::Client.new()
# Create a sensor object, that uses the client:
s = STSPlatform::Sensors.new(c, SENSOR_NAME)
# Print the sensor object:
res = s.get()
puts res.data
puts res.code
# To acccess data from a sensor create a data object that uses the sensor object
d = STSPlatform::Data.new(s)
# Print the last data point. Do a get request on the data resource, passing
# a parameter: "beforeE", according to:
# http://wotkit.readthedocs.org/en/latest/api_v1/api_sensor_data.html#raw-data-retrieval
res = d.get({beforeE:1})
puts res.data
puts res.code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment