public
Rubygem
Description: object to xml mapping library
Homepage: http://happymapper.rubyforge.org
Clone URL: git://github.com/jnunemaker/happymapper.git
Click here to lend your support to: happymapper and make a donation at www.pledgie.com !
happymapper / examples / post.rb
100644 19 lines (15 sloc) 0.519 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'happymapper')
 
file_contents = File.read(dir + '/../spec/fixtures/posts.xml')
 
class Post
  include HappyMapper
  
  attribute :href, String
  attribute :hash, String
  attribute :description, String
  attribute :tag, String
  attribute :time, DateTime
  attribute :others, Integer
  attribute :extended, String
end
 
posts = Post.parse(file_contents)
posts.each { |post| puts post.description, post.href, post.extended, '' }