File: posts.rb

package info (click to toggle)
ruby-roxml 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 800 kB
  • sloc: ruby: 4,133; xml: 1,013; makefile: 7
file content (27 lines) | stat: -rwxr-xr-x 607 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby
require_relative './../spec/spec_helper'

class Post
  include ROXML
  
  xml_reader :href, :from => :attr
  xml_reader :hash, :from => :attr
  xml_reader :description, :from => :attr
  xml_reader :tag, :from => :attr
  xml_reader :created_at, :from => '@time'
  xml_reader :others, :from => :attr, :as => Integer
  xml_reader :extended, :from => :attr
end

class Posts
  include ROXML

  xml_reader :posts, :as => [Post]
end

unless defined?(RSpec)
  posts = Posts.from_xml(xml_for('posts'))
  posts.posts.each do |post|
    puts post.description, post.href, post.extended, ''
  end
end