Class: SocketLabs::InjectionApi::Message::CustomHeader
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Message::CustomHeader
- 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
-
#name ⇒ Object
the name of the custom header.
-
#value ⇒ Object
the value of the custom header.
Instance Method Summary collapse
-
#initialize(name = nil, value = nil) ⇒ CustomHeader
constructor
Initializes a new instance of the CustomHeader class.
-
#is_valid ⇒ Boolean
Determines if the CustomHeader is valid.
-
#to_s ⇒ String
Represents the CustomHeader name-value pair as a String.
Constructor Details
#initialize(name = nil, value = nil) ⇒ CustomHeader
Initializes a new instance of the CustomHeader class
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
#name ⇒ Object
the name of the custom header
19 20 21 |
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 19 def name @name end |
#value ⇒ Object
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_valid ⇒ Boolean
Determines if the CustomHeader is valid.
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_s ⇒ String
Represents the CustomHeader name-value pair as a String
45 46 47 |
# File 'lib/socketlabs/injectionapi/message/custom_header.rb', line 45 def to_s "#{@name}, #{@value}" end |