Sha256: a22a7cfad9bde29dd12120c71c89e3de4e213959b22970764a91d58bd9cdf724

Contents?: true

Size: 1.29 KB

Versions: 32

Compression:

Stored size: 1.29 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'
require 'yaml'

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')

#Example: print out its eeml representation
puts "Output as EEML"
puts env.to_eeml

#Example: print out its json representation
puts "Output as JSON"
puts env.to_json


#Example: parse an environment from an eeml doc:
puts "\nParsing an environment from a local 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: configure a different logger (to file; to stderr; different timestamp / format; use an existing rails logger)

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
eeml-0.0.42 example.rb
eeml-0.0.41 example.rb
eeml-0.0.40 example.rb
eeml-0.0.39 example.rb
eeml-0.0.38 example.rb
eeml-0.0.37 example.rb
eeml-0.0.36 example.rb
eeml-0.0.35 example.rb
eeml-0.0.34 example.rb
eeml-0.0.33 example.rb
eeml-0.0.32 example.rb
eeml-0.0.29 example.rb
eeml-0.0.25 example.rb
eeml-0.0.24 example.rb
eeml-0.0.23 example.rb
eeml-0.0.22 example.rb
eeml-0.0.21 example.rb
eeml-0.0.18 example.rb
eeml-0.0.17 example.rb
eeml-0.0.14 example.rb