Class: MSG_Chumby::LastReadingHandler
- Inherits:
-
Mongrel::HttpHandler
- Object
- Mongrel::HttpHandler
- MSG_Chumby::LastReadingHandler
- Defined in:
- lib/msg-chumby-daemon/http-xml-server.rb
Instance Method Summary collapse
-
#initialize(reading_cache) ⇒ LastReadingHandler
constructor
A new instance of LastReadingHandler.
- #process(request, response) ⇒ Object
Constructor Details
#initialize(reading_cache) ⇒ LastReadingHandler
Returns a new instance of LastReadingHandler.
36 37 38 |
# File 'lib/msg-chumby-daemon/http-xml-server.rb', line 36 def initialize(reading_cache) @reading_cache=reading_cache; end |
Instance Method Details
#process(request, response) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/msg-chumby-daemon/http-xml-server.rb', line 39 def process(request, response) response.start(200) do |head,out| head["Content-Type"] = "text/xml" reading=(@reading_cache.last_reading()) reading = Flukso::UTCReading.new(Time.now.to_i, 0.0) if reading==nil; time=Time.at(reading.); current_reading= {'time' => [ time.strftime("%H:%M:%S")], 'reading' => [reading.value]}; out.write(XmlSimple.xml_out( current_reading,{'RootName' => "current_reading"})); end end |