Class: Twinkies::UrlList
- Inherits:
-
Object
- Object
- Twinkies::UrlList
- Includes:
- Enumerable
- Defined in:
- lib/twinkies/url_list.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(*strings) ⇒ UrlList
constructor
A new instance of UrlList.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*strings) ⇒ UrlList
Returns a new instance of UrlList.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/twinkies/url_list.rb', line 5 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 |
Instance Method Details
#==(other) ⇒ Object
29 30 31 |
# File 'lib/twinkies/url_list.rb', line 29 def ==(other) @urls == other end |
#each(&block) ⇒ Object
17 18 19 |
# File 'lib/twinkies/url_list.rb', line 17 def each(&block) @urls.each &block end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/twinkies/url_list.rb', line 21 def inspect @urls.inspect end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/twinkies/url_list.rb', line 25 def to_s @urls.to_s end |