Sha256: 9142ab866626a564c8784f70850c25faf6e6447ab99edf2222bb12536083d856
Contents?: true
Size: 660 Bytes
Versions: 2
Compression:
Stored size: 660 Bytes
Contents
module TaskManager class NewTaskFile < TaskFile def pick(id) node = root_node.css('task').find { |t| t['id'].to_i == id.to_i } raise 'ID not exists'.colorize(:light_red) unless node task = Task.new_from_node(node) yield(task) if block_given? handle_xml { node.remove } task end protected def root_node @root_node ||= begin xml.css(NEW_NODE).first || begin node = xml.create_element(NEW_NODE) super.add_child(node) node end end end def create_node(task) node = super node['created_at'] = time_now node end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
task_manager2-0.0.13 | lib/task_manager/new_task_file.rb |
task_manager2-0.0.12 | lib/task_manager/new_task_file.rb |