Class: Shrimp::Source
- Inherits:
-
Object
- Object
- Shrimp::Source
- Defined in:
- lib/shrimp/source.rb
Instance Method Summary collapse
- #file? ⇒ Boolean
- #html? ⇒ Boolean
-
#initialize(url_or_file) ⇒ Source
constructor
A new instance of Source.
- #to_s ⇒ Object
- #url? ⇒ Boolean
Constructor Details
#initialize(url_or_file) ⇒ Source
Returns a new instance of Source.
4 5 6 7 |
# File 'lib/shrimp/source.rb', line 4 def initialize(url_or_file) @source = url_or_file raise ImproperSourceError.new unless url? || file? end |
Instance Method Details
#file? ⇒ Boolean
13 14 15 |
# File 'lib/shrimp/source.rb', line 13 def file? @source.kind_of?(File) end |
#html? ⇒ Boolean
17 18 19 |
# File 'lib/shrimp/source.rb', line 17 def html? !(url? || file?) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/shrimp/source.rb', line 21 def to_s file? ? @source.path : @source end |
#url? ⇒ Boolean
9 10 11 |
# File 'lib/shrimp/source.rb', line 9 def url? @source.is_a?(String) && @source.match(URI::regexp) end |