Sha256: e8aec55a16cab7a87bb55e5d28be8248e804bd092a1d8b2bff903d49b9270f26

Contents?: true

Size: 768 Bytes

Versions: 4

Compression:

Stored size: 768 Bytes

Contents

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

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

class MultiStreetAddress
  include HappyMapper
  
  tag 'address'
  
  # allow primitive type to be collection
  has_many :street_address, String, :tag => "streetaddress"
  element :city, String
  element :state_or_province, String, :tag => "stateOrProvince"
  element :zip, String
  element :country, String
end

multi = MultiStreetAddress.parse(file_contents)

puts "Street Address:"

multi.street_address.each do |street|
  puts street
end

puts "City: #{multi.city}"
puts "State/Province: #{multi.state_or_province}"
puts "Zip: #{multi.zip}"
puts "Country: #{multi.country}"

Version data entries

4 entries across 4 versions & 2 rubygems

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