Class: Smplkit::Config::ConfigItem

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/config/models.rb

Overview

A single typed item in a Config.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, value:, type:, description: nil) ⇒ ConfigItem

Returns a new instance of ConfigItem.



19
20
21
22
23
24
# File 'lib/smplkit/config/models.rb', line 19

def initialize(name:, value:, type:, description: nil)
  @name = name
  @value = value
  @type = type
  @description = description
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



17
18
19
# File 'lib/smplkit/config/models.rb', line 17

def description
  @description
end

#nameObject

Returns the value of attribute name.



17
18
19
# File 'lib/smplkit/config/models.rb', line 17

def name
  @name
end

#typeObject

Returns the value of attribute type.



17
18
19
# File 'lib/smplkit/config/models.rb', line 17

def type
  @type
end

#valueObject

Returns the value of attribute value.



17
18
19
# File 'lib/smplkit/config/models.rb', line 17

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



30
31
32
33
# File 'lib/smplkit/config/models.rb', line 30

def ==(other)
  other.is_a?(ConfigItem) && other.name == @name && other.value == @value &&
    other.type == @type && other.description == @description
end

#hashObject



36
# File 'lib/smplkit/config/models.rb', line 36

def hash = [@name, @value, @type, @description].hash

#to_hObject



26
27
28
# File 'lib/smplkit/config/models.rb', line 26

def to_h
  { "name" => @name, "value" => @value, "type" => @type, "description" => @description }.compact
end