Sha256: 6033c9769d73d1b3d51205f0e64f23a744a24116b593456f2b40511140ece670

Contents?: true

Size: 865 Bytes

Versions: 16

Compression:

Stored size: 865 Bytes

Contents

#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper')

class Base
  include ROXML
  xml_convention :dasherize
  xml_namespace 'aws'
end

class WeatherObservation < Base
  xml_name 'ob'
  xml_reader :temperature, :as => Float, :from => 'aws:temp'
  xml_reader :feels_like, :as => Integer
  xml_reader :current_condition #, :attributes => {:icon => String} # pending
end

class Weather < Base
  xml_reader :observation, :as => WeatherObservation, :required => true
end

unless defined?(Spec)
  current_weather = Weather.from_xml(xml_for('current_weather')).observation
  puts "temperature: #{current_weather.temperature}"
  puts "feels_like: #{current_weather.feels_like}"
  puts "current_condition: #{current_weather.current_condition}"
# puts "current_condition.icon: #{current_weather.current_condition.icon}"  # pending
end

Version data entries

16 entries across 16 versions & 5 rubygems

Version Path
Empact-roxml-2.5.1 examples/current_weather.rb
Empact-roxml-2.5.2 examples/current_weather.rb
Empact-roxml-2.5.3 examples/current_weather.rb
doxo-roxml-2.5.3 examples/current_weather.rb
yob-roxml-3.1.6 examples/current_weather.rb
roxml-3.1.5 examples/current_weather.rb
roxml-3.1.4 examples/current_weather.rb
roxml-3.1.3 examples/current_weather.rb
roxml-3.1.2 examples/current_weather.rb
roxml-3.1.1 examples/current_weather.rb
roxml-3.1.0 examples/current_weather.rb
ROXML-3.0.0 examples/current_weather.rb
roxml-2.5.1 examples/current_weather.rb
roxml-2.5.0 examples/current_weather.rb
roxml-2.5.2 examples/current_weather.rb
roxml-2.5.3 examples/current_weather.rb