lib/rubyfocus/items/project.rb in rubyfocus-0.5.6 vs lib/rubyfocus/items/project.rb in rubyfocus-0.5.9
- old
+ new
@@ -1,16 +1,19 @@
# The project represents an OmniFocus project object.
class Rubyfocus::Project < Rubyfocus::Task
- # It's parseable
include Rubyfocus::Parser
#-------------------------------------------------------------------------------
# Parsing stuff
# Projects are <task>s with an interior <project> node
def self.matches_node?(node)
- return (node.name == "task" && (node/"project").size > 0)
+ return (
+ node.name == "task" &&
+ (node/"project").size > 0 &&
+ (node/"project").first.children.size > 0
+ )
end
# Singleton: contains one-off tasks
attr_accessor :singleton
@@ -62,13 +65,14 @@
def on_hold?; status == :inactive; end
def completed?; status == :done; end
def dropped?; status == :dropped; end
#---------------------------------------
- # Convert to a task
+ # Convert to a task. Does not supply a document, as this would overwrite current project
def to_task
- t = Rubyfocus::Task.new(self.document)
+ 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
\ No newline at end of file