Sha256: b7283f8df3855484c1cc24aeacb9d592ac8f0b0d79a054d902b8c7733135831f

Contents?: true

Size: 769 Bytes

Versions: 10

Compression:

Stored size: 769 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 'aws:ob'
  element :temperature, Integer, :tag => 'aws:temp'
  element :feels_like, Integer, :tag => 'aws:feels-like'
  element :current_condition, String, :tag => 'aws: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

10 entries across 10 versions & 3 rubygems

Version Path
gotascii-happymapper-0.1.6 examples/current_weather.rb
jnunemaker-happymapper-0.1.3 examples/current_weather.rb
jnunemaker-happymapper-0.1.4 examples/current_weather.rb
jnunemaker-happymapper-0.1.5 examples/current_weather.rb
jnunemaker-happymapper-0.1.6 examples/current_weather.rb
jnunemaker-happymapper-0.1.7 examples/current_weather.rb
happymapper-0.1.4 examples/current_weather.rb
happymapper-0.1.6 examples/current_weather.rb
happymapper-0.1.7 examples/current_weather.rb
happymapper-0.1.3 examples/current_weather.rb