Class: RubyTodo::Template
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RubyTodo::Template
- Defined in:
- lib/ruby_todo/models/template.rb
Instance Method Summary collapse
-
#create_task(notebook, replacements = {}) ⇒ Object
Create a task from this template.
Instance Method Details
#create_task(notebook, replacements = {}) ⇒ Object
Create a task from this template
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_todo/models/template.rb', line 13 def create_task(notebook, replacements = {}) # Process the title with replacements title = process_pattern(title_pattern, replacements) # Process the description with replacements if it exists description = description_pattern ? process_pattern(description_pattern, replacements) : nil # Process tags if they exist = ? process_pattern(, replacements) : nil # Calculate due date due_date = calculate_due_date(due_date_offset) if due_date_offset # Create the task Task.create( notebook: notebook, title: title, description: description, status: "todo", priority: priority, tags: , due_date: due_date ) end |