Sha256: 5f8a5006eb1f4c01d3fe9b2ff9848f020303550f1203c0cb05458d222075b40a

Contents?: true

Size: 362 Bytes

Versions: 2

Compression:

Stored size: 362 Bytes

Contents

module Terminus
  class Headers

    def initialize(values)
      @hash = {}
      values.each do |key, value|
        @hash[normalize_key(key)] = value
      end
    end

    def [](key)
      @hash[normalize_key(key)]
    end

  private

    def normalize_key(key)
      key.downcase.
          gsub(/^http_/, '').
          gsub(/_/, '-')
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
terminus-0.6.0 lib/terminus/headers.rb
terminus-0.5.0 lib/terminus/headers.rb