module Todo::Helpers::Tasks

Helper methods used in the Todo::Tasks module

Public Instance Methods

update_task(is_num, names, task, key, value) click to toggle source

Update a task

@param [Bool] is_num is the task a number @param [Dataset] names a dataset of all the tasks in the working list @param task the task name or number that we are updating @param [Symbol] key the key we are updating @param [Integer] value the value that we are changing it too.

# File lib/to-do/helpers/helpers_tasks.rb, line 15
def update_task is_num, names, task, key, value
        if is_num
                found_task = names[:Task_number => task]
                if found_task
                        Helpers::DATABASE[:Tasks].filter(:Id => found_task[:Id]).update(key => value)
                else
                        puts "Task ##{task} is not in the list."
                end
        else
                found_task = names.with_sql("SELECT * FROM :table WHERE Name = :task COLLATE NOCASE",:table=>names, :task=>task).first
                if found_task
                        Helpers::DATABASE[:Tasks].filter(:Id => found_task[:Id]).update(key => value)
                else
                        puts "Task '#{task}' is not in the list."
                end
        end
end