Class: Connect::Code
- Inherits:
-
Object
- Object
- Connect::Code
- Defined in:
- lib/connect/code.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, value) ⇒ Code
constructor
A new instance of Code.
- #inspect ⇒ Object
Constructor Details
#initialize(name, value) ⇒ Code
33 34 35 36 |
# File 'lib/connect/code.rb', line 33 def initialize(name, value) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/connect/code.rb', line 31 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
31 32 33 |
# File 'lib/connect/code.rb', line 31 def value @value end |
Class Method Details
.from_http_code(code) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/connect/code.rb', line 6 def from_http_code(code) case code.to_i when 200 then Ok when 400 then InvalidArgument when 401 then Unauthenticated when 403 then PermissionDenied when 404 then NotFound when 408 then DeadlineExceeded when 409 then Aborted when 412 then FailedPrecondition when 413 then ResourceExhausted when 415 then Internal when 429 then Unavailable when 431 then ResourceExhausted when 502, 503, 504 then Unavailable else Unknown end end |
.from_name(name) ⇒ Object
26 27 28 |
# File 'lib/connect/code.rb', line 26 def from_name(name) CODES_BY_NAME.fetch(name, Unknown) end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/connect/code.rb', line 38 def ==(other) other.is_a?(Code) && name == other.name && value == other.value end |
#inspect ⇒ Object
42 43 44 |
# File 'lib/connect/code.rb', line 42 def inspect "#<#{self.class.name} name=#{name.inspect} value=#{value.inspect}>" end |