Sha256: f7bffbfb03aab0bd0e18ae186b53f60e466e1f2d10a4927d694ccf7a1f341db2

Contents?: true

Size: 629 Bytes

Versions: 6

Compression:

Stored size: 629 Bytes

Contents

module Twinkies
  class UrlList
    include Enumerable

    def initialize(*strings)
      strings = strings.first if strings.size == 1 && strings.first.is_a?(Array)
      @urls = strings.inject([]) do |urls, string|
        if block_given?
          yield(string).scan(/http:\/\/\S+/) {|s| urls << {:item => string, :url => s}}
          urls
        else
          urls += string.scan(/http:\/\/\S+/)
        end
      end
    end

    def each(&block)
      @urls.each &block
    end

    def inspect
      @urls.inspect
    end

    def to_s
      @urls.to_s
    end

    def ==(other)
      @urls == other
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pat-maddox-twinkies-0.1.0 lib/twinkies/url_list.rb
pat-maddox-twinkies-0.1.1 lib/twinkies/url_list.rb
pat-maddox-twinkies-0.1.2 lib/twinkies/url_list.rb
pat-maddox-twinkies-0.1.3 lib/twinkies/url_list.rb
pat-maddox-twinkies-0.1.4 lib/twinkies/url_list.rb
pat-maddox-twinkies-0.1.5 lib/twinkies/url_list.rb