Class: UrlFinder::BaseReader
- Inherits:
-
Object
- Object
- UrlFinder::BaseReader
- Includes:
- Enumerable
- Defined in:
- lib/url_finder/readers/base_reader.rb
Overview
Base class for reader implementations
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
-
.urls(*args) ⇒ BaseReader
Alias for #new.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Yield each url.
-
#empty? ⇒ true, false
Returns true if no URLs were found.
-
#initialize(content) ⇒ BaseReader
constructor
Initialize reader.
-
#to_a ⇒ Array<String>
Returns the URLs as an array.
- #urls ⇒ Object
Constructor Details
#initialize(content) ⇒ BaseReader
Initialize reader
18 19 20 21 |
# File 'lib/url_finder/readers/base_reader.rb', line 18 def initialize(content) @content = content @urls = nil end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/url_finder/readers/base_reader.rb', line 14 def content @content end |
Class Method Details
.urls(*args) ⇒ BaseReader
Alias for #new
8 9 10 |
# File 'lib/url_finder/readers/base_reader.rb', line 8 def self.urls(*args) new(*args) end |
Instance Method Details
#each(&block) ⇒ Object
Yield each url
25 26 27 |
# File 'lib/url_finder/readers/base_reader.rb', line 25 def each(&block) urls.each(&block) end |
#empty? ⇒ true, false
Returns true if no URLs were found
36 37 38 |
# File 'lib/url_finder/readers/base_reader.rb', line 36 def empty? urls.empty? end |
#to_a ⇒ Array<String>
Returns the URLs as an array
42 43 44 |
# File 'lib/url_finder/readers/base_reader.rb', line 42 def to_a urls end |
#urls ⇒ Object
30 31 32 |
# File 'lib/url_finder/readers/base_reader.rb', line 30 def urls raise(NotImplementedError, 'subclass must implement!') end |