Class: Onebox::StatusCheck
- Inherits:
-
Object
- Object
- Onebox::StatusCheck
- Defined in:
- lib/onebox/status_check.rb
Instance Method Summary collapse
- #human_status ⇒ Object
-
#initialize(url, options = Onebox.options) ⇒ StatusCheck
constructor
A new instance of StatusCheck.
- #ok? ⇒ Boolean
- #status ⇒ Object
Constructor Details
#initialize(url, options = Onebox.options) ⇒ StatusCheck
Returns a new instance of StatusCheck.
5 6 7 8 9 |
# File 'lib/onebox/status_check.rb', line 5 def initialize(url, = Onebox.) @url = url @options = @status = -1 end |
Instance Method Details
#human_status ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/onebox/status_check.rb', line 20 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
11 12 13 |
# File 'lib/onebox/status_check.rb', line 11 def ok? status > 199 && status < 300 end |
#status ⇒ Object
15 16 17 18 |
# File 'lib/onebox/status_check.rb', line 15 def status check if @status == -1 @status end |