Class: Ingenico::Connect::SDK::RequestHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/ingenico/connect/sdk/request_header.rb

Overview

Represents HTTP request headers Each header is immutable has a #name and #value attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ RequestHeader

Create a new header using the name and value given as parameters.



8
9
10
11
12
13
14
# File 'lib/ingenico/connect/sdk/request_header.rb', line 8

def initialize(name, value)
  if name.nil? || name.strip.empty?
    raise ArgumentError.new('name is required')
  end
  @name = name
  @value = normalize_value(value)
end

Instance Attribute Details

#nameObject (readonly)

HTTP header name



17
18
19
# File 'lib/ingenico/connect/sdk/request_header.rb', line 17

def name
  @name
end

#valueObject (readonly)

HTTP header value



19
20
21
# File 'lib/ingenico/connect/sdk/request_header.rb', line 19

def value
  @value
end

Instance Method Details

#to_sObject



21
22
23
# File 'lib/ingenico/connect/sdk/request_header.rb', line 21

def to_s
  "#{name}:#{value}"
end