Class: Begin::ValueTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/begin/config.rb

Overview

Represents a tag with a single value. Value tags can have a default value assigned in the config. If the user chooses not to enter a value, the default value is substituted instead.

Instance Attribute Summary collapse

Attributes inherited from Tag

#array, #key, #label

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, label, array, default) ⇒ ValueTag

Returns a new instance of ValueTag.



61
62
63
64
# File 'lib/begin/config.rb', line 61

def initialize(key, label, array, default)
  super key, label, array
  @default = default
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



59
60
61
# File 'lib/begin/config.rb', line 59

def default
  @default
end

Class Method Details

.from_config(key, value) ⇒ Object



66
67
68
69
70
71
# File 'lib/begin/config.rb', line 66

def self.from_config(key, value)
  array = value.include?('array') ? value['array'] : false
  label = value.include?('label') ? value['label'] : key
  default = value.include?('default') ? value['default'] : ''
  ValueTag.new key, label, array, default
end