Class: Guillotine::WildcardHostChecker
- Inherits:
-
RegexHostChecker
- Object
- HostChecker
- RegexHostChecker
- Guillotine::WildcardHostChecker
- Defined in:
- lib/guillotine/host_checkers.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Attributes inherited from RegexHostChecker
Attributes inherited from HostChecker
Class Method Summary collapse
- .match?(arg) ⇒ Boolean (also: host_from)
Instance Method Summary collapse
-
#initialize(pattern) ⇒ WildcardHostChecker
constructor
A new instance of WildcardHostChecker.
Methods inherited from RegexHostChecker
Methods inherited from HostChecker
all, #call, #error_response, matching, #valid?
Constructor Details
#initialize(pattern) ⇒ WildcardHostChecker
Returns a new instance of WildcardHostChecker.
80 81 82 83 84 85 86 |
# File 'lib/guillotine/host_checkers.rb', line 80 def initialize(pattern) @pattern = pattern @host = self.class.host_from(pattern) @regex = %r{(^|\.)#{Regexp.escape @host}$} super(@regex) @error = "URL must be from #{@host}" end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
78 79 80 |
# File 'lib/guillotine/host_checkers.rb', line 78 def host @host end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
78 79 80 |
# File 'lib/guillotine/host_checkers.rb', line 78 def pattern @pattern end |
Class Method Details
.match?(arg) ⇒ Boolean Also known as: host_from
70 71 72 |
# File 'lib/guillotine/host_checkers.rb', line 70 def self.match?(arg) arg.to_s =~ /^\*\.([\w\.]+)$/ && $1 end |