Class: Context

Inherits:
Object
  • Object
show all
Includes:
Status
Defined in:
lib/gtd.rb

Direct Known Subclasses

ContextFromDirectory, Inbox, Project

Constant Summary

Constants included from Status

Status::ACTIVE_STATES, Status::INACTIVE_STATES, Status::STATUS_ORDER, Status::STATUS_SYMBOLS, Status::SYMBOLS_STATUS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Status

#active, #directory_name, #inactive, #index, #symbol, #with_status

Constructor Details

#initialize(name = 'None') ⇒ Context

Returns a new instance of Context.



28
29
30
31
# File 'lib/gtd.rb', line 28

def initialize(name='None')
  @name = name
  @actions = []
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



26
27
28
# File 'lib/gtd.rb', line 26

def actions
  @actions
end

#nameObject (readonly)

Returns the value of attribute name.



26
27
28
# File 'lib/gtd.rb', line 26

def name
  @name
end

Instance Method Details

#<<(action) ⇒ Object



33
34
35
36
# File 'lib/gtd.rb', line 33

def <<(action)
  @actions << action
  action.context = self
end

#delete(action) ⇒ Object



40
41
42
# File 'lib/gtd.rb', line 40

def delete(action)
  @actions.delete action
end

#include?(action) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/gtd.rb', line 37

def include?(action)
  @actions.include? action
end

#to_sObject



43
44
45
# File 'lib/gtd.rb', line 43

def to_s
  "Context #{@name}:\n  " + @actions.join("\n  ")
end