Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

evan farrar

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

part of a chump parser / viewer

   1  
   2  require 'rubygems'
   3  require 'rexml/document'
   4  require 'markaby'
   5  class Chump
   6    chump = REXML::Document.new(File.new( "chump.xml" ))
   7    mab = Markaby::Builder.new
   8    mab.html do
   9      head { title "The Daily Chump" }
  10      body do
  11        h1 "The Daily Chump"
  12        ul do
  13          chump.elements.each("churn/link") do |el|
  14            unless el.attributes['type'] == 'blurb'
  15              title = el.elements['title'] ? el.elements['title'].text : el.elements['url'].text
  16              link = a title, :href => el.elements['url'].text
  17              li link<< " - posted by "<< el.elements['nick'].text
  18            else
  19              li el.elements['title'].text if el.elements['title']
  20            end
  21             li "posted at "<< el.elements['time'].text
  22          end
  23        end
  24      end
  25    end
  26    puts mab.to_s
  27  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS