Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Forked from acdimalev/gist:300157
Created February 10, 2010 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmmanuelOga/300300 to your computer and use it in GitHub Desktop.
Save EmmanuelOga/300300 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
class Array
module RegexpIndexing
def [] a
a.is_a?(Regexp) ? select {|b| b.is_a?(String) && b[a]} : super
end
end
def with_rx
self.class.ancestors.include?(RegexpIndexing) ? dup : dup.tap {|s|s.extend(RegexpIndexing)}
end
end
doc = Nokogiri::XML.parse(open("http://www.8bitpeoples.com/feed/feed.rss"))
links = doc.xpath("//link").map {|link| link.content}
albums = links.with_rx[/discography/].map {|link| link[-6..-1]}
print albums.join("\n") + "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment