Sha256: 45c9ed95d43e9353badf7cedd9cd0469e9d8a7aa795b9b284bb8b0ed2c26817a
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
#!/usr/bin/env ruby #should invoke this with (e.g.) ruby -Ilib example.rb in order to add lib/ to your search path require 'rubygems' #only if your libxml is installed under rubygems require 'eeml' include Eeml #allows you to refer to Environment rather than Eeml::Environment #Example: make an environment from scratch env = Environment.new(:creator => 'http://www.example.com/ourstudio/', :feed_url => 'http://www.example.com/ourstudio/feeds/house.xml') env.title = 'my example feed' env.datastreams << DataStream.new(:value => 93.0, :identifier => 'room.1.humidity') env.datastreams << DataStream.new(:value => 91.0, :identifier => 'room.2.humidity') #print out its eeml representation puts env.to_eeml #Example: parse an environment from an eeml doc: eeml_str = File.read('test/data/doc_1.xml') env2 = Environment.new_from_eeml(eeml_str) env2.datastreams.each do |ds| puts "ds %8s value is %6s (min:%8s, max:%8s)" %[ds.identifier, ds.value, ds.min_value, ds.max_value] end #TODO: Example: http-fetch an environment #TODO: Example: publish an environment to pachube #TODO: Example: configure a different logger (to file; to stderr; different timestamp / format; use an existing rails logger)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eeml-0.0.1 | example.rb |