Class: MSG_Chumby::Reading_Cache
- Inherits:
-
Object
- Object
- MSG_Chumby::Reading_Cache
- Defined in:
- lib/msg-chumby-daemon/reading-cache.rb
Instance Method Summary collapse
-
#initialize ⇒ Reading_Cache
constructor
A new instance of Reading_Cache.
- #last_day ⇒ Object
- #last_hour ⇒ Object
- #last_minute ⇒ Object
- #last_reading ⇒ Object
- #update_last_day(readings) ⇒ Object
- #update_last_hour(readings) ⇒ Object
- #update_last_minute(readings) ⇒ Object
- #update_last_reading(reading) ⇒ Object
Constructor Details
#initialize ⇒ Reading_Cache
Returns a new instance of Reading_Cache.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 5 def initialize @last_reading=nil; @last_reading_mutex=Mutex.new(); @last_minute=nil; @last_minute_mutex=Mutex.new(); @last_hour=nil; @last_hour_mutex=Mutex.new(); @last_day=nil; @last_day_mutex=Mutex.new(); end |
Instance Method Details
#last_day ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 61 def last_day retval=nil @last_day_mutex.synchronize do retval=@last_day end return retval end |
#last_hour ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 48 def last_hour retval=nil @last_hour_mutex.synchronize do retval=@last_hour end return retval end |
#last_minute ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 34 def last_minute retval=nil @last_minute_mutex.synchronize do retval=@last_minute end return retval end |
#last_reading ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 21 def last_reading retval=nil @last_reading_mutex.synchronize do retval=@last_reading end return retval end |
#update_last_day(readings) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 55 def update_last_day(readings) raise "Please provide an Array instance" if readings.class != Array @last_day_mutex.synchronize do @last_day=readings end end |
#update_last_hour(readings) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 42 def update_last_hour(readings) raise "Please provide an Array instance" if readings.class != Array @last_hour_mutex.synchronize do @last_hour=readings end end |
#update_last_minute(readings) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 28 def update_last_minute(readings) raise "Please provide an Array instance" if readings.class != Array @last_minute_mutex.synchronize do @last_minute=readings end end |
#update_last_reading(reading) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/msg-chumby-daemon/reading-cache.rb', line 15 def update_last_reading(reading) raise "Please provide a UTCReading instance" if reading.class != Flukso::UTCReading @last_reading_mutex.synchronize do @last_reading=reading end end |