Class: Begin::HashTag
Overview
Represents a nested object hash tag. On encountering a hash tag, the user is prompted to enter a value for each member of the hash.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Attributes inherited from Tag
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, label, array, children) ⇒ HashTag
constructor
A new instance of HashTag.
Constructor Details
#initialize(key, label, array, children) ⇒ HashTag
Returns a new instance of HashTag.
81 82 83 84 |
# File 'lib/begin/config.rb', line 81 def initialize(key, label, array, children) super key, label, array @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
79 80 81 |
# File 'lib/begin/config.rb', line 79 def children @children end |
Class Method Details
.from_config(key, value) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/begin/config.rb', line 97 def self.from_config(key, value) array = value.include?('array') ? value['array'] : false label = value.include?('label') ? value['label'] : key children = value.include?('tags') ? from_config_hash(value) : [] HashTag.new key, label, array, children end |
.from_config_hash(config) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/begin/config.rb', line 86 def self.from_config_hash(config) return [] unless config.include?('tags') && config['tags'].is_a?(Hash) config['tags'].each.map do |key, value| raise "Invalid template. Expected value of '#{key}' to be a Hash" \ unless value.is_a? Hash Tag.from_config key, value end end |