Class: Dialers::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/dialers/status.rb

Overview

A wrapper over an HTTP status to answer some questions related to what a state means.

Instance Method Summary collapse

Constructor Details

#initialize(status) ⇒ Status


4
5
6
# File 'lib/dialers/status.rb', line 4

def initialize(status)
  self.status = status
end

Instance Method Details

#accepted?Boolean


45
46
47
# File 'lib/dialers/status.rb', line 45

def accepted?
  is?(202)
end

#bad_request?Boolean


55
56
57
# File 'lib/dialers/status.rb', line 55

def bad_request?
  is?(400)
end

#client_error?Boolean


25
26
27
# File 'lib/dialers/status.rb', line 25

def client_error?
  initial_letter == "4"
end

#created?Boolean


40
41
42
# File 'lib/dialers/status.rb', line 40

def created?
  is?(201)
end

#is?(code) ⇒ Boolean


10
11
12
# File 'lib/dialers/status.rb', line 10

def is?(code)
  status.to_i == code.to_i
end

#method_not_allowed?Boolean


70
71
72
# File 'lib/dialers/status.rb', line 70

def method_not_allowed?
  is?(405)
end

#no_content?Boolean


50
51
52
# File 'lib/dialers/status.rb', line 50

def no_content?
  is?(204)
end

#not_found?Boolean


65
66
67
# File 'lib/dialers/status.rb', line 65

def not_found?
  is?(404)
end

#ok?Boolean


35
36
37
# File 'lib/dialers/status.rb', line 35

def ok?
  is?(200)
end

#redirect?Boolean


20
21
22
# File 'lib/dialers/status.rb', line 20

def redirect?
  initial_letter == "3"
end

#server_error?Boolean


30
31
32
# File 'lib/dialers/status.rb', line 30

def server_error?
  initial_letter == "5"
end

#success?Boolean


15
16
17
# File 'lib/dialers/status.rb', line 15

def success?
  initial_letter == "2"
end

#unauthorized?Boolean


60
61
62
# File 'lib/dialers/status.rb', line 60

def unauthorized?
  is?(401)
end