class OCI::ResponseHeaders

A readonly, case-insensitive http response header collection

Public Class Methods

new(headers) click to toggle source

Initialize the readonly and case-insensitive http response headers with hash object.

@param [Hash] headers the hash object contains http response headers.

# File lib/oci/response_headers.rb, line 10
def initialize(headers)
  @headers = {}
  return if headers.nil?

  headers.each do |key, value|
    key = key.downcase if key.is_a? String
    @headers[key] = value.is_a?(Array) && value.length == 1 ? value[0] : value
  end
end

Public Instance Methods

[](key) click to toggle source

Element Reference-Retrieves the value object corresponding to the key object. If not found, returns nil.

@param [Object] key the key object. It is case-insensitive if it is a String object.

# File lib/oci/response_headers.rb, line 24
def [](key)
  key = key.downcase if key.is_a? String
  @headers[key] || nil
end
each(&block) click to toggle source

Calls block once for each key in hsh, passing the key-value pair as parameters. If no block is given, an enumerator is returned instead.

@param [Block] block the callback block

# File lib/oci/response_headers.rb, line 33
def each(&block)
  @headers.each(&block)
end
Also aliased as: each_pair
each_key(&block) click to toggle source

Calls block once for each key in hsh, passing the key as a parameter. If no block is given, an enumerator is returned instead.

@param [Block] block the callback block

# File lib/oci/response_headers.rb, line 41
def each_key(&block)
  @headers.each_key(&block)
end
each_pair(&block)

Alias for: each

Alias for: each
each_value(&block) click to toggle source

Calls block once for each key in hsh, passing the value as a parameter. If no block is given, an enumerator is returned instead.

@param [Block] block the callback block

# File lib/oci/response_headers.rb, line 52
def each_value(&block)
  @headers.each_value(&block)
end
empty?() click to toggle source

Returns true if hsh contains no key-value pairs.

# File lib/oci/response_headers.rb, line 57
def empty?
  @headers.empty?
end
eql?(other) click to toggle source

Returns true if hash and other are both hashes with the same content.

# File lib/oci/response_headers.rb, line 62
def eql?(other)
  @headers.eql?(other)
end
fetch(key, *args, &block) click to toggle source

Returns a value from the hash for the given key. If the key cannot be found, there are several options: With no other arguments, it will raise an KeyError exception; if default is given, then that will be returned; if the optional code block is specified, then that will be run and its result returned.

# File lib/oci/response_headers.rb, line 69
def fetch(key, *args, &block)
  key = key.downcase if key.is_a? String
  @headers.fetch(key, *args, &block)
end
has_key?(key)

Alias for: key?

Alias for: key?
has_value?(value)

Alias for: value?

Alias for: value?
hash() click to toggle source

Compute a hash-code for this hash. Two hashes with the same content will have the same hash code (and will compare using eql?).

# File lib/oci/response_headers.rb, line 97
def hash
  @headers.hash
end
include?(key)

Alias for: key?

Alias for: key?
inspect()

Alias for: to_s

Alias for: to_s
key(value) click to toggle source

Returns the key of an occurrence of a given value. If the value is not found, returns nil.

@param [Object] value to check.

# File lib/oci/response_headers.rb, line 115
def key(value)
  @headers.key(value)
end
key?(key) click to toggle source

Returns true if the given key is present in hsh.

@param [Object] key to check. It is case-insensitive if it is a String object.

# File lib/oci/response_headers.rb, line 77
def key?(key)
  key = key.downcase if key.is_a? String
  @headers.key?(key)
end
Also aliased as: has_key?, include?, member?
keys() click to toggle source

Returns a new array populated with the keys from this hash.

# File lib/oci/response_headers.rb, line 120
def keys
  @headers.keys
end
length()

Alias for: size

Alias for: size
member?(key)

Alias for: key?

Alias for: key?
size() click to toggle source

Returns the number of key-value pairs in the hash.

# File lib/oci/response_headers.rb, line 125
def size
  @headers.size
end
Also aliased as: length
to_hash() click to toggle source

Returns the hash object.

# File lib/oci/response_headers.rb, line 136
def to_hash
  @headers
end
to_s() click to toggle source

Return the contents of this hash as a string.

# File lib/oci/response_headers.rb, line 105
def to_s
  @headers.to_s
end
Also aliased as: inspect
value?(value) click to toggle source

Returns true if the given value is present for some key in hsh.

@param [Object] value to check.

# File lib/oci/response_headers.rb, line 88
def value?(value)
  @headers.value?(value)
end
Also aliased as: has_value?
values() click to toggle source

Returns a new array populated with the values from hsh.

# File lib/oci/response_headers.rb, line 141
def values
  @headers.values
end