Class: Pipe
- Inherits:
-
Object
- Object
- Pipe
- Defined in:
- lib/pipe.rb
Constant Summary collapse
- VERSION =
'0.1.0'- HEADER =
%q{<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel>}- FOOTER =
%q{</channel></rss>}
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
Instance Method Summary collapse
- #feed(url, filters = {}) ⇒ Object
-
#initialize ⇒ Pipe
constructor
A new instance of Pipe.
Constructor Details
#initialize ⇒ Pipe
Returns a new instance of Pipe.
18 19 20 |
# File 'lib/pipe.rb', line 18 def initialize @content = "" end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/pipe.rb', line 10 def content @content end |
Class Method Details
Instance Method Details
#feed(url, filters = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/pipe.rb', line 22 def feed(url,filters={}) doc = Hpricot.XML(open(url)) @content += (doc/:item).select do |item| filters.all? { |field,pattern| (item/field).to_s =~ pattern } end.to_s end |