class Utopia::HTTP::Status

A small HTTP status wrapper that verifies the status code within a given range.

Public Class Methods

new(code, valid_range = 100...600) click to toggle source
# File lib/utopia/http.rb, line 99
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

Public Instance Methods

each() { |to_s| ... } click to toggle source

Allow to be used for rack body:

# File lib/utopia/http.rb, line 120
def each
        yield to_s
end
to_i() click to toggle source
# File lib/utopia/http.rb, line 111
def to_i
        @code
end
to_s() click to toggle source
# File lib/utopia/http.rb, line 115
def to_s
        STATUS_DESCRIPTIONS[@code] || @code.to_s
end