This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Funked Out Java+Ruby Aggregator
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Tim Bray. What a newb. But for being a Ruby nuby, he’s already posting hacks like he’s got recalescent digits. This JRuby stuff he’s got up right now makes me whinny!
# Rename Java's Data class as JDate in Ruby
include_class('java.util.Date') {|p,n| "J" + n }
# Use Java's RSS/XML libs to fill a Ruby array
ARGV.each do |arg|
feed = SyndFeedInput.new.build(XmlReader.new(URL.new(arg)))
feed.entries.each do |entry|
entry.setTitle "#{feed.getTitle}: #{entry.getTitle}"
aEntries << entry
end
end
# Sort the entries in Ruby
aEntries = aEntries.select { |e| e.getPublishedDate.between?(earlier, now) }
aEntries.sort! { |a, b| b.getPublishedDate <=> a.getPublishedDate }
aFeed.setEntries aEntries
Get the picture? The script of note is here. (The original agog struck on Tim’s blog.)