Class: Template
- Inherits:
-
Object
- Object
- Template
- Defined in:
- lib/things_templates/template.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(file) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(file) ⇒ Template
Returns a new instance of Template.
6 7 8 9 10 11 |
# File 'lib/things_templates/template.rb', line 6 def initialize(file) yaml = YAML.load(File.open(file)) @items = yaml['items'] @project = yaml.fetch('project', nil) @tags = yaml.fetch('tags', nil) end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
4 5 6 |
# File 'lib/things_templates/template.rb', line 4 def items @items end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
4 5 6 |
# File 'lib/things_templates/template.rb', line 4 def project @project end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
4 5 6 |
# File 'lib/things_templates/template.rb', line 4 def @tags end |
Instance Method Details
#build! ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/things_templates/template.rb', line 13 def build! if project ThingsController.add_items_to_project(project, items, ) else items.each do |item| ThingsController.add_item(item) end end end |