Sha256: ac3c8edb38a3ab972878f8c566efa51231c5656749b52a370d23211f762f0e38

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

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

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

class User
  include HappyMapper
  
  element :id, Integer
  element :name, String
  element :screen_name, String
  element :location, String
  element :description, String
  element :profile_image_url, String
  element :url, String
  element :protected, Boolean
  element :followers_count, Integer
end

class Status
  include HappyMapper
  
  element :id, Integer
  element :text, String
  element :created_at, Time
  element :source, String
  element :truncated, Boolean
  element :in_reply_to_status_id, Integer
  element :in_reply_to_user_id, Integer
  element :favorited, Boolean
  has_one :user, User
end

statuses = Status.parse(file_contents)
statuses.each do |status|
  puts status.user.name, status.user.screen_name, status.text, status.source, ''
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
happymapper-0.5.0 examples/twitter.rb