Class: Onebox::StatusCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/onebox/status_check.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, options = Onebox.options) ⇒ StatusCheck

Returns a new instance of StatusCheck.


3
4
5
6
7
# File 'lib/onebox/status_check.rb', line 3

def initialize(url, options = Onebox.options)
  @url = url
  @options = options
  @status = -1
end

Instance Method Details

#human_statusObject


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/onebox/status_check.rb', line 18

def human_status
  case status
  when 0
    :connection_error
  when 200..299
    :success
  when 400..499
    :client_error
  when 500..599
    :server_error
  else
    :unknown_error
  end
end

#ok?Boolean

Returns:

  • (Boolean)

9
10
11
# File 'lib/onebox/status_check.rb', line 9

def ok?
  status > 199 && status < 300
end

#statusObject


13
14
15
16
# File 'lib/onebox/status_check.rb', line 13

def status
  check if @status == -1
  @status
end