Class: Recluse::Result
- Inherits:
-
Object
- Object
- Recluse::Result
- Defined in:
- lib/recluse/result.rb
Overview
Very simple result container.
Instance Attribute Summary collapse
-
#code ⇒ Object
HTTP status code.
-
#error ⇒ Object
Access error message.
Instance Method Summary collapse
-
#color ⇒ Object
Color based on code.
-
#initialize(code, error) ⇒ Result
constructor
Create a result.
-
#inspect ⇒ Object
Returns the HTTP status code.
Constructor Details
#initialize(code, error) ⇒ Result
Create a result.
15 16 17 18 |
# File 'lib/recluse/result.rb', line 15 def initialize(code, error) @code = code @error = error end |
Instance Attribute Details
#code ⇒ Object
HTTP status code.
7 8 9 |
# File 'lib/recluse/result.rb', line 7 def code @code end |
#error ⇒ Object
Access error message.
11 12 13 |
# File 'lib/recluse/result.rb', line 11 def error @error end |
Instance Method Details
#color ⇒ Object
Color based on code.
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/recluse/result.rb', line 28 def color case (@code.to_i / 100) when 2 color = :green when 3 color = :yellow when 4, 5 color = :red else color = :blue end color end |
#inspect ⇒ Object
Returns the HTTP status code.
22 23 24 |
# File 'lib/recluse/result.rb', line 22 def inspect @code.to_s end |