Class: MSG_Chumby::LastDayImporter
- Inherits:
-
Object
- Object
- MSG_Chumby::LastDayImporter
- Defined in:
- lib/msg-chumby-daemon/reading-importer.rb
Instance Method Summary collapse
- #doWork ⇒ Object
-
#initialize(reading_cache, sensor_id, token) ⇒ LastDayImporter
constructor
A new instance of LastDayImporter.
Constructor Details
#initialize(reading_cache, sensor_id, token) ⇒ LastDayImporter
Returns a new instance of LastDayImporter.
74 75 76 77 78 79 |
# File 'lib/msg-chumby-daemon/reading-importer.rb', line 74 def initialize(reading_cache, sensor_id, token) @reading_cache=reading_cache auth=Flukso::TokenAuth.new(token); @api=Flukso::API.new(auth, BASE_URL); @query=Flukso::QueryReadings.new(sensor_id, :day, :watt) end |
Instance Method Details
#doWork ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/msg-chumby-daemon/reading-importer.rb', line 80 def doWork begin readings=@query.execute(@api); rescue Exception => e puts "Query failed: #{e}" puts "Used #{BASE_URL} as BASE_URL" exit(-10); end #puts "Got Response:" #readings.each{|reading| # puts reading #} @reading_cache.update_last_day(readings); end |