class Dialers::Status
A wrapper over an HTTP status to answer some questions related to what a state means.
Attributes
status[RW]
Public Class Methods
new(status)
click to toggle source
# File lib/dialers/status.rb, line 4 def initialize(status) self.status = status end
Public Instance Methods
accepted?()
click to toggle source
@return [Boolean] wether the status is 202.
# File lib/dialers/status.rb, line 45 def accepted? is?(202) end
bad_request?()
click to toggle source
@return [Boolean] wether the status is 400.
# File lib/dialers/status.rb, line 55 def bad_request? is?(400) end
client_error?()
click to toggle source
@return [Boolean] wether the status is a 4xx one.
# File lib/dialers/status.rb, line 25 def client_error? initial_letter == "4" end
created?()
click to toggle source
@return [Boolean] wether the status is 201.
# File lib/dialers/status.rb, line 40 def created? is?(201) end
is?(code)
click to toggle source
@param code [Fixnum] The code to compare @return [Boolean] wether the status is the argument
# File lib/dialers/status.rb, line 10 def is?(code) status.to_i == code.to_i end
method_not_allowed?()
click to toggle source
@return [Boolean] wether the status is 405.
# File lib/dialers/status.rb, line 70 def method_not_allowed? is?(405) end
no_content?()
click to toggle source
@return [Boolean] wether the status is 204.
# File lib/dialers/status.rb, line 50 def no_content? is?(204) end
not_found?()
click to toggle source
@return [Boolean] wether the status is 404.
# File lib/dialers/status.rb, line 65 def not_found? is?(404) end
ok?()
click to toggle source
@return [Boolean] wether the status is 200.
# File lib/dialers/status.rb, line 35 def ok? is?(200) end
redirect?()
click to toggle source
@return [Boolean] wether the status is a 3xx one.
# File lib/dialers/status.rb, line 20 def redirect? initial_letter == "3" end
server_error?()
click to toggle source
@return [Boolean] wether the status is a 5xx one.
# File lib/dialers/status.rb, line 30 def server_error? initial_letter == "5" end
success?()
click to toggle source
@return [Boolean] wether the status is a 2xx one.
# File lib/dialers/status.rb, line 15 def success? initial_letter == "2" end
Private Instance Methods
initial_letter()
click to toggle source
# File lib/dialers/status.rb, line 76 def initial_letter @initial_letter ||= status.to_s[0] end