Sha256: 403a4ce59578876c13f529b30e98cb7301320591414e2b1afb5fb4d36e6113ab
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
#TODO: Read PR article about require and require relative require_relative "todo/version" require_relative "todo/version" require_relative "todo/list" require_relative 'todo/presenter' module Todo class Application def initialize(persistent: false) @list = init_list(persistent) @presenter = Todo::Presenter.new end def add(name:, **options) @list.add(name: name, priority: options[:priority], list: options[:list]) end def finish(task_name, **options) if options[:list] access_list(options[:list]).finish(task_name) else @list.finish(task_name) end end def remove(task_name) @list.remove(task_name) end def tasks(options={}) item = options[:list] ? access_list(options[:list]) : @list return "no such list" unless item @presenter.present(item: item, info: :tasks, level: options[:level]) end def lists @presenter.present(item: @list, info: :lists) end def access_list(list_name) @list.access_list(list_name) end private def init_list(persistent) if persistent Todo::List.load else Todo::List.new end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
2do-0.0.2 | lib/todo.rb |