Class: Guillotine::HostChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/guillotine/host_checkers.rb

Direct Known Subclasses

RegexHostChecker, StringHostChecker

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg = nil) ⇒ HostChecker

Returns a new instance of HostChecker.



16
17
18
# File 'lib/guillotine/host_checkers.rb', line 16

def initialize(arg = nil)
  @error_response = [422, {}, @error]
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



14
15
16
# File 'lib/guillotine/host_checkers.rb', line 14

def error
  @error
end

#error_responseObject (readonly)

Returns the value of attribute error_response.



14
15
16
# File 'lib/guillotine/host_checkers.rb', line 14

def error_response
  @error_response
end

Class Method Details

.allObject



10
11
12
# File 'lib/guillotine/host_checkers.rb', line 10

def self.all
  @all ||= []
end

.matching(arg) ⇒ Object



3
4
5
6
7
8
# File 'lib/guillotine/host_checkers.rb', line 3

def self.matching(arg)
  case arg
  when HostChecker then arg
  else (all.detect { |ch| ch.match?(arg) } || self).new(arg)
  end
end

Instance Method Details

#call(url) ⇒ Object



24
25
26
# File 'lib/guillotine/host_checkers.rb', line 24

def call(url)
  @error_response unless valid?(url)
end

#valid?(url) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/guillotine/host_checkers.rb', line 20

def valid?(url)
  true
end