Class: Sanford::Protocol::ResponseStatus::Code

Inherits:
Struct
  • Object
show all
Defined in:
lib/sanford-protocol/response_status.rb

Constant Summary collapse

NAMES =
{
  200 => 'OK',
  400 => 'BAD REQUEST',
  404 => 'NOT FOUND',
  408 => 'TIMEOUT',
  422 => 'INVALID',
  500 => 'ERROR'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Code

Returns a new instance of Code.



38
39
40
41
# File 'lib/sanford-protocol/response_status.rb', line 38

def initialize(number)
  n = number.to_i
  super(n, NAMES[n])
end

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



28
29
30
# File 'lib/sanford-protocol/response_status.rb', line 28

def name
  @name
end

#numberObject

Returns the value of attribute number

Returns:

  • (Object)

    the current value of number



28
29
30
# File 'lib/sanford-protocol/response_status.rb', line 28

def number
  @number
end

Instance Method Details

#to_sObject



43
# File 'lib/sanford-protocol/response_status.rb', line 43

def to_s; "[#{[number, name].compact.join(', ')}]"; end