Sha256: 2d9e1cf144cf4e789ee9be72756cff0b4acf37a683064cb22bee72fa711b9bfd

Contents?: true

Size: 774 Bytes

Versions: 30

Compression:

Stored size: 774 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 '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

30 entries across 30 versions & 11 rubygems

Version Path
dam5s-happymapper-0.3.2 examples/current_weather.rb
jimmyz-happymapper-0.3.1 examples/current_weather.rb
jimmyz-happymapper-0.3.2 examples/current_weather.rb
jimmyz-happymapper-0.3.3 examples/current_weather.rb
jnunemaker-happymapper-0.2.1 examples/current_weather.rb
jnunemaker-happymapper-0.2.2 examples/current_weather.rb
jnunemaker-happymapper-0.2.3 examples/current_weather.rb
jnunemaker-happymapper-0.2.4 examples/current_weather.rb
jnunemaker-happymapper-0.2.5 examples/current_weather.rb
kdonovan-happymapper-0.3.4 examples/current_weather.rb
kdonovan-happymapper-0.3.5 examples/current_weather.rb
lightningdb-happymapper-0.3.0 examples/current_weather.rb
lightningdb-happymapper-0.3.1 examples/current_weather.rb
lightningdb-happymapper-0.3.2 examples/current_weather.rb
macasek-happymapper-0.2.5 examples/current_weather.rb
macasek-happymapper-0.2.6 examples/current_weather.rb
robmitch-happymapper-0.2.5 examples/current_weather.rb
kdonovan-happymapper-0.3.7 examples/current_weather.rb
happymapper-0.3.2 examples/current_weather.rb
nokogiri-happymapper-0.3.4 examples/current_weather.rb