Class: TodoTxtViewer::TaskLine

Inherits:
Object
  • Object
show all
Defined in:
lib/todo_txt_viewer/task_line.rb

Constant Summary collapse

ALLOWED_ACTIONS =
i(do! undo! priority_inc! priority_dec!).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task) ⇒ TaskLine

Returns a new instance of TaskLine.



9
10
11
# File 'lib/todo_txt_viewer/task_line.rb', line 9

def initialize task
  @task = task
end

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



7
8
9
# File 'lib/todo_txt_viewer/task_line.rb', line 7

def task
  @task
end

Instance Method Details

#task_action(action) ⇒ Object



17
18
19
20
21
# File 'lib/todo_txt_viewer/task_line.rb', line 17

def task_action action
  raise "illegal action #{action}" unless ALLOWED_ACTIONS.include? action

  task.send action
end

#to_sObject



13
14
15
# File 'lib/todo_txt_viewer/task_line.rb', line 13

def to_s
  task.to_s
end