Sha256: 0fef2269a73e50327d1cfec40bf3f09a6ed150ca9548cf7130b9aeddf3c16523

Contents?: true

Size: 833 Bytes

Versions: 9

Compression:

Stored size: 833 Bytes

Contents

#!/usr/bin/env ruby
require_relative './../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?(RSpec)
  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

9 entries across 9 versions & 1 rubygems

Version Path
roxml-4.2.0 examples/current_weather.rb
roxml-4.1.1 examples/current_weather.rb
roxml-4.1.0 examples/current_weather.rb
roxml-4.0.0 examples/current_weather.rb
roxml-3.3.1 examples/current_weather.rb
roxml-3.3.0 examples/current_weather.rb
roxml-3.2.2 examples/current_weather.rb
roxml-3.2.1 examples/current_weather.rb
roxml-3.2.0 examples/current_weather.rb