Sha256: 967d30ddaa195ba3c1694dea1c2533242c3bfd5d391f1007ff1219d73b7bf47e

Contents?: true

Size: 560 Bytes

Versions: 5

Compression:

Stored size: 560 Bytes

Contents

module TaskManager
  class NewTaskFile < TaskFile
    def pick(id)
      node = root_node.css('task').find { |t| t['id'].to_i == id }
      task = Task.new_from_node(node)
      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

5 entries across 5 versions & 1 rubygems

Version Path
task_manager2-0.0.5 lib/task_manager/new_task_file.rb
task_manager2-0.0.4 lib/task_manager/new_task_file.rb
task_manager2-0.0.3 lib/task_manager/new_task_file.rb
task_manager2-0.0.2 lib/task_manager/new_task_file.rb
task_manager2-0.0.1 lib/task_manager/new_task_file.rb