Class: PRSS::Links
- Inherits:
-
Object
- Object
- PRSS::Links
- Defined in:
- lib/prss/links.rb
Instance Method Summary collapse
- #channel ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(xml) ⇒ Links
constructor
A new instance of Links.
- #links ⇒ Object
Constructor Details
#initialize(xml) ⇒ Links
Returns a new instance of Links.
5 6 7 |
# File 'lib/prss/links.rb', line 5 def initialize(xml) @xml = xml end |
Instance Method Details
#channel ⇒ Object
9 10 11 |
# File 'lib/prss/links.rb', line 9 def channel @channel ||= Nokogiri::XML.parse(@xml).xpath('//channel') end |
#each(&block) ⇒ Object
19 20 21 22 23 |
# File 'lib/prss/links.rb', line 19 def each(&block) links.each do |link| yield link.content end end |
#links ⇒ Object
13 14 15 16 17 |
# File 'lib/prss/links.rb', line 13 def links channel.xpath('//item/link').tap do |links| puts "Found #{links.size} links" end end |