Sha256: 2f721c5c48dcaa3ed4988db8da249eacc1ca4c1b2444261934dacb511f97d301

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

require 'nokogiri'
require 'rexml/document'
require 'uri'

module PRSS
  class Links
    def initialize(xml)
      @xml = ::REXML::Document.new(xml)
    end

    attr_reader :xml

    def links
      xml.elements.to_a('//item/link').tap do |links|
        puts "Found #{links.size} links"
      end
    end

    def each
      return to_enum unless block_given?

      links.each do |link|
        yield URI(link.text.strip)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prss-0.2.0 lib/prss/links.rb