Class: PRSS::Links

Inherits:
Object
  • Object
show all
Defined in:
lib/prss/links.rb

Instance Method Summary collapse

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

#channelObject



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


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