Class: SocketLabs::InjectionApi::Message::Metadata
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Message::Metadata
- Defined in:
- lib/socketlabs/injectionapi/message/metadata.rb
Overview
Represents metadata as a key-value pair. Example:
= Metadata.new
.key = "key1"
.value = "value1"
= Metadata.new("key2", "value2")
Instance Attribute Summary collapse
-
#key ⇒ Object
the key of the metadata item.
-
#value ⇒ Object
the value of the metadata item.
Instance Method Summary collapse
-
#initialize(key = nil, value = nil) ⇒ Metadata
constructor
Initializes a new instance of the Metadata class.
-
#is_valid ⇒ Boolean
Determines if the Metadata is valid.
-
#to_s ⇒ String
Represents the Metadata key-value pair as a String.
Constructor Details
#initialize(key = nil, value = nil) ⇒ Metadata
Initializes a new instance of the Metadata class
26 27 28 29 30 31 32 |
# File 'lib/socketlabs/injectionapi/message/metadata.rb', line 26 def initialize( key = nil, value = nil ) @key = key @value = value end |
Instance Attribute Details
#key ⇒ Object
the key of the metadata item
19 20 21 |
# File 'lib/socketlabs/injectionapi/message/metadata.rb', line 19 def key @key end |
#value ⇒ Object
the value of the metadata item
21 22 23 |
# File 'lib/socketlabs/injectionapi/message/metadata.rb', line 21 def value @value end |
Instance Method Details
#is_valid ⇒ Boolean
Determines if the Metadata is valid.
36 37 38 39 40 41 |
# File 'lib/socketlabs/injectionapi/message/metadata.rb', line 36 def is_valid valid_key = !(@key.nil? || @key.empty?) valid_value = !(@value.nil? || @value.empty?) valid_key && valid_value end |
#to_s ⇒ String
Represents the Metadata key-value pair as a String
45 46 47 |
# File 'lib/socketlabs/injectionapi/message/metadata.rb', line 45 def to_s "#{@key}, #{@value}" end |