Class: WaybackArchiver::HTTPCode
- Inherits:
-
Object
- Object
- WaybackArchiver::HTTPCode
- Defined in:
- lib/wayback_archiver/http_code.rb
Overview
Convience class for HTTP response codes
Class Method Summary collapse
-
.error?(code) ⇒ Boolean
Whether the code is a error type.
-
.redirect?(code) ⇒ Boolean
Whether the code is a redirect type.
-
.success?(code) ⇒ Boolean
Whether the code is a success type.
-
.type(code) ⇒ Symbol
Type of code as symbol.
Class Method Details
.error?(code) ⇒ Boolean
Whether the code is a error type
45 46 47 |
# File 'lib/wayback_archiver/http_code.rb', line 45 def self.error?(code) !!code.to_s.match(/4\d\d/) || !!code.to_s.match(/5\d\d/) end |
.redirect?(code) ⇒ Boolean
Whether the code is a redirect type
36 37 38 |
# File 'lib/wayback_archiver/http_code.rb', line 36 def self.redirect?(code) !!code.to_s.match(/3\d\d/) end |
.success?(code) ⇒ Boolean
Whether the code is a success type
27 28 29 |
# File 'lib/wayback_archiver/http_code.rb', line 27 def self.success?(code) !!code.to_s.match(/2\d\d/) end |
.type(code) ⇒ Symbol
Type of code as symbol
9 10 11 12 13 14 15 16 |
# File 'lib/wayback_archiver/http_code.rb', line 9 def self.type(code) code = code.to_s return :success if success?(code) return :redirect if redirect?(code) return :error if error?(code) :unknown end |