Class: PRSS::Links
- Inherits:
-
Object
- Object
- PRSS::Links
- Defined in:
- lib/prss/links.rb
Defined Under Namespace
Classes: InvalidXMLError
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(xml) ⇒ Links
constructor
A new instance of Links.
- #links ⇒ Object
Constructor Details
#initialize(xml) ⇒ Links
Returns a new instance of Links.
8 9 10 11 12 |
# File 'lib/prss/links.rb', line 8 def initialize(xml) @xml = ::REXML::Document.new(xml) rescue REXML::ParseException raise InvalidXMLError end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
14 15 16 |
# File 'lib/prss/links.rb', line 14 def xml @xml end |
Instance Method Details
#each ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/prss/links.rb', line 22 def each return to_enum unless block_given? links.each do |link| yield URI(link.text.strip) end end |
#links ⇒ Object
16 17 18 19 20 |
# File 'lib/prss/links.rb', line 16 def links xml.elements.to_a('//item/link').tap do |links| puts "Found #{links.size} links" end end |