Class: Guillotine::RegexHostChecker
- Inherits:
-
HostChecker
- Object
- HostChecker
- Guillotine::RegexHostChecker
- Defined in:
- lib/guillotine/host_checkers.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Attributes inherited from HostChecker
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(regex) ⇒ RegexHostChecker
constructor
A new instance of RegexHostChecker.
- #valid?(url) ⇒ Boolean
Methods inherited from HostChecker
Constructor Details
#initialize(regex) ⇒ RegexHostChecker
Returns a new instance of RegexHostChecker.
36 37 38 39 40 |
# File 'lib/guillotine/host_checkers.rb', line 36 def initialize(regex) @error = "URL must match #{regex.inspect}" @regex = regex super end |
Instance Attribute Details
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
34 35 36 |
# File 'lib/guillotine/host_checkers.rb', line 34 def regex @regex end |
Class Method Details
.match?(arg) ⇒ Boolean
30 31 32 |
# File 'lib/guillotine/host_checkers.rb', line 30 def self.match?(arg) arg.is_a?(Regexp) end |
Instance Method Details
#valid?(url) ⇒ Boolean
42 43 44 |
# File 'lib/guillotine/host_checkers.rb', line 42 def valid?(url) url.host.to_s =~ @regex end |