Class: Rubyfocus::Project
- Includes:
- Parser
- Defined in:
- lib/rubyfocus/items/project.rb
Overview
The project represents an OmniFocus project object.
Instance Attribute Summary collapse
-
#last_review ⇒ Object
When did we last review the project?.
-
#review_interval ⇒ Object
How often to we review this project?.
-
#singleton ⇒ Object
(also: #singleton?)
Singleton: contains one-off tasks.
-
#status ⇒ Object
What’s the status of the project? Valid options: :active, :inactive, :done.
Attributes inherited from Task
#completed, #due, #flagged, #note, #order, #start
Attributes inherited from RankedItem
Attributes inherited from NamedItem
Attributes inherited from Item
#added, #document, #id, #modified
Class Method Summary collapse
-
.matches_node?(node) ⇒ Boolean
Projects are <task>s with an interior <project> node.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Status methods.
-
#apply_xml(n) ⇒ Object
Apply XML node to project.
- #completed? ⇒ Boolean
- #dropped? ⇒ Boolean
-
#initialize(document = nil, n = nil) ⇒ Project
constructor
Initialize the project with a document and optional node to base it off of.
- #on_hold? ⇒ Boolean
-
#to_task ⇒ Object
————————————— Convert to a task.
Methods included from Parser
Methods inherited from Task
#actionable_tasks, #blocked?, #deferred?, #has_subtasks?, #immediate_tasks, #incomplete_tasks, #next_available_immediate_task, #next_available_task, #next_tasks, #tasks, #tasks_remain?, #to_project
Methods inherited from RankedItem
Methods inherited from NamedItem
Methods inherited from Item
Methods included from ConditionalExec
Methods included from IDRef
Constructor Details
#initialize(document = nil, n = nil) ⇒ Project
Initialize the project with a document and optional node to base it off of. Also sets default values
32 33 34 35 36 37 |
# File 'lib/rubyfocus/items/project.rb', line 32 def initialize(document=nil, n=nil) @singleton = false @order = :sequential @status = :active super(document, n) end |
Instance Attribute Details
#last_review ⇒ Object
When did we last review the project?
24 25 26 |
# File 'lib/rubyfocus/items/project.rb', line 24 def last_review @last_review end |
#review_interval ⇒ Object
How often to we review this project?
21 22 23 |
# File 'lib/rubyfocus/items/project.rb', line 21 def review_interval @review_interval end |
#singleton ⇒ Object Also known as: singleton?
Singleton: contains one-off tasks
18 19 20 |
# File 'lib/rubyfocus/items/project.rb', line 18 def singleton @singleton end |
#status ⇒ Object
What’s the status of the project? Valid options: :active, :inactive, :done. Default is :active
28 29 30 |
# File 'lib/rubyfocus/items/project.rb', line 28 def status @status end |
Class Method Details
.matches_node?(node) ⇒ Boolean
Projects are <task>s with an interior <project> node
9 10 11 12 13 14 15 |
# File 'lib/rubyfocus/items/project.rb', line 9 def self.matches_node?(node) return ( node.name == "task" && (node/"project").size > 0 && (node/"project").first.children.size > 0 ) end |
Instance Method Details
#active? ⇒ Boolean
Status methods
67 |
# File 'lib/rubyfocus/items/project.rb', line 67 def active?; status == :active; end |
#apply_xml(n) ⇒ Object
Apply XML node to project
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubyfocus/items/project.rb', line 40 def apply_xml(n) super(n) #First, set project p = n.at_xpath("xmlns:project") # We're not always going to have a project! And this *doesn't* mean that this project is demoted if p conditional_set(:singleton, p.at_xpath("xmlns:singleton")) { |e| e.inner_html == "true" } conditional_set(:review_interval, p.at_xpath("xmlns:review-interval") ) { |e| Rubyfocus::ReviewPeriod.from_string(e.inner_html) } conditional_set(:last_review, p.at_xpath("xmlns:last-review")) { |e| Time.safely_parse e.inner_html } conditional_set(:status, p.at_xpath("xmlns:status")) { |e| e.inner_html.to_sym } end end |
#completed? ⇒ Boolean
69 |
# File 'lib/rubyfocus/items/project.rb', line 69 def completed?; status == :done; end |
#dropped? ⇒ Boolean
70 |
# File 'lib/rubyfocus/items/project.rb', line 70 def dropped?; status == :dropped; end |
#on_hold? ⇒ Boolean
68 |
# File 'lib/rubyfocus/items/project.rb', line 68 def on_hold?; status == :inactive; end |
#to_task ⇒ Object
Convert to a task. Does not supply a document, as this would overwrite current project
74 75 76 77 78 79 80 81 82 |
# File 'lib/rubyfocus/items/project.rb', line 74 def to_task t = Rubyfocus::Task.new(nil) instance_variables.each do |ivar| next if ivar == :"@document" setter = ivar.to_s.gsub(/^@/,"") + "=" t.send(setter, self.instance_variable_get(ivar)) if t.respond_to?(setter) end t end |