Class: SocketLabs::InjectionApi::Message::CustomHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/socketlabs/injectionapi/message/custom_header.rb

Overview

Represents a custom header as a name-value pair. Example:

header1 = CustomHeader.new
header1.name = "name1"
header1.value = "value1"

header2 = CustomHeader.new("name2", "value2")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, value = nil) ⇒ CustomHeader

Initializes a new instance of the CustomHeader class

Parameters:

  • name (String) (defaults to: nil)
  • value (String) (defaults to: nil)


26
27
28
29
30
31
32
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 26

def initialize(
    name = nil,
    value = nil
)
  @name = name
  @value = value
end

Instance Attribute Details

#nameObject

the name of the custom header



19
20
21
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 19

def name
  @name
end

#valueObject

the value of the custom header



21
22
23
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 21

def value
  @value
end

Instance Method Details

#is_validBoolean

Determines if the CustomHeader is valid.

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 36

def is_valid
  valid_name = !(@name.nil? || @name.empty?)
  valid_value = !(@value.nil? || @value.empty?)

  valid_name && valid_value
end

#to_sString

Represents the CustomHeader name-value pair as a String

Returns:

  • (String)


45
46
47
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 45

def to_s
    "#{@name}, #{@value}"
end