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
all, #call, #error_response, matching
Constructor Details
#initialize(regex) ⇒ RegexHostChecker
Returns a new instance of RegexHostChecker.
40 41 42 43 44 |
# File 'lib/guillotine/host_checkers.rb', line 40 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.
38 39 40 |
# File 'lib/guillotine/host_checkers.rb', line 38 def regex @regex end |
Class Method Details
.match?(arg) ⇒ Boolean
34 35 36 |
# File 'lib/guillotine/host_checkers.rb', line 34 def self.match?(arg) arg.is_a?(Regexp) end |
Instance Method Details
#valid?(url) ⇒ Boolean
46 47 48 |
# File 'lib/guillotine/host_checkers.rb', line 46 def valid?(url) url.host.to_s =~ @regex end |