Class: CollectionJSON::TemplateBuilder
- Inherits:
-
Object
- Object
- CollectionJSON::TemplateBuilder
- Defined in:
- lib/collection-json/builder.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #add_data(name, value = '', prompt = '') ⇒ Object
-
#initialize(data) ⇒ TemplateBuilder
constructor
A new instance of TemplateBuilder.
Constructor Details
#initialize(data) ⇒ TemplateBuilder
Returns a new instance of TemplateBuilder.
97 98 99 |
# File 'lib/collection-json/builder.rb', line 97 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
95 96 97 |
# File 'lib/collection-json/builder.rb', line 95 def data @data end |
Instance Method Details
#add_data(name, value = '', prompt = '') ⇒ Object
101 102 103 104 105 106 |
# File 'lib/collection-json/builder.rb', line 101 def add_data(name, value = '', prompt = '') data << Data.from_hash({'name' => name}).tap do |data| data.merge!({'value' => value}) if value != '' data.merge!({'prompt' => prompt}) if prompt != '' end end |