Class: Pipe
Constants
| Name | Value |
|---|---|
| VERSION | '0.1.2' |
| HEADER | %q{<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel>} |
| FOOTER | %q{</channel></rss>} |
Attributes
| Name | Read/write? |
|---|---|
| content | R |
Public Class Methods
create (&block)
# File lib/pipe.rb, line 12 def self.create(&block) pipe = Pipe.new if block.arity.zero? pipe.instance_eval(&block) else block.call(pipe) end HEADER + pipe.content + FOOTER end
Public Instance Methods
feed (url,filters={})
# File lib/pipe.rb, line 28 def feed(url,filters={}) enum = (filters[:combine_with] == :or ? :any? : :all?) filters.delete(:combine_with) doc = Hpricot.XML(open(url)) @content += (doc/:item).select do |item| filters.send(enum) { |field,pattern| (item/field).to_s =~ pattern } end.to_s end