Sha256: 8a5554b73d4f843cdd92ced0ba82dab41af45b72443d625d0415742f75911f02

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

module Rapidoc

  ##
  # Represent http status code with code and description.
  # Also include bootstrap label for code.
  #
  class HttpResponse

    attr_reader :code, :description, :label

    def initialize( code )
      @code = code
      @description = get_description
      @label = get_label
    end

    def get_description
      case @code
        when 200
          'OK'
        when 201
          'Created'
        when 204
          'No content'
        when 401
          'Access Denied'
        when 403
          'Forbidden'
        when 404
          'Not found'
        when 422
          'Unprocessable Entity'
        when 400
          'Bad Request'
        else
          ''
      end
    end

    def get_label
      case @code
        when 200
          'label label-info'
        when 201
          'label label-success'
        when 204
          'label label-info2'
        when 401
          'label label-warning'
        when 403
          'label label-warning2'
        when 422
          'label label-important'
        when 404
          'label label-inverse'
        else
          'label'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rapidoc-0.0.7 lib/rapidoc/http_response.rb