Class: Utopia::HTTP::Status
- Inherits:
-
Object
- Object
- Utopia::HTTP::Status
- Defined in:
- lib/utopia/http.rb
Overview
A small HTTP status wrapper that verifies the status code within a given range.
Instance Method Summary collapse
-
#each {|to_s| ... } ⇒ Object
Allow to be used for rack body:.
-
#initialize(code, valid_range = 100...600) ⇒ Status
constructor
A new instance of Status.
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(code, valid_range = 100...600) ⇒ Status
Returns a new instance of Status.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/utopia/http.rb', line 82 def initialize(code, valid_range = 100...600) if code.is_a? Symbol code = STATUS_CODES[code] end unless valid_range.include? code raise ArgumentError.new("Status must be in range #{valid_range}, was given #{code}!") end @code = code end |
Instance Method Details
#each {|to_s| ... } ⇒ Object
Allow to be used for rack body:
103 104 105 |
# File 'lib/utopia/http.rb', line 103 def each yield to_s end |
#to_i ⇒ Object
94 95 96 |
# File 'lib/utopia/http.rb', line 94 def to_i @code end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/utopia/http.rb', line 98 def to_s STATUS_DESCRIPTIONS[@code] || @code.to_s end |