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
Constructor Details
#initialize(pattern) ⇒ WildcardHostChecker
Returns a new instance of WildcardHostChecker.
76 77 78 79 80 81 82 |
# File 'lib/guillotine/host_checkers.rb', line 76 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.
74 75 76 |
# File 'lib/guillotine/host_checkers.rb', line 74 def host @host end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
74 75 76 |
# File 'lib/guillotine/host_checkers.rb', line 74 def pattern @pattern end |
Class Method Details
.match?(arg) ⇒ Boolean Also known as: host_from
66 67 68 |
# File 'lib/guillotine/host_checkers.rb', line 66 def self.match?(arg) arg.to_s =~ /^\*\.([\w\.]+)$/ && $1 end |