Sha256: 373932df74f545761cd6fc827f2b8492d71ca86d2bd48f461f1075595627cc0e

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'happymapper')

file_contents = File.read(dir + '/../spec/fixtures/current_weather.xml')

class CurrentWeather
  include HappyMapper
  
  tag 'ob'
  namespace 'http://www.aws.com/aws'
  element :temperature, Integer, :tag => 'temp'
  element :feels_like, Integer, :tag => 'feels-like'
  element :current_condition, String, :tag => 'current-condition', :attributes => {:icon => String}
end

CurrentWeather.parse(file_contents).each do |current_weather|
  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}"
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
happymapper-0.5.0 examples/current_weather.rb
happymapper-0.4.1 examples/current_weather.rb
happymapper-swanandp-0.4.0 examples/current_weather.rb
happymapper-0.4.0 examples/current_weather.rb