Кристиян обнови решението на 06.11.2013 14:00 (преди около 11 години)
+class Task
+ attr_accessor :status, :description, :priority, :tags
+ def initiate_task task_line
+ @status,@description = task_line.split("|")[0],task_line.split("|")[1]
+ @priority = task_line.split("|")[2]
+ @tags = task_line.split("|")[3].split(",")
+ return self
+ end
+
+ def ==(other_task)
+ stat_comp,tags_comp=(@status == other_task.status),(@tags == other_task.tags)
+ desc_comp = (@description == other_task.description)
+ prio_comp = (@priority == other_task.priority)
+ if(stat_comp&desc_comp&prio_comp&tags_comp) then return true end
+ end
+end
+
+class ToDoList
+ attr_accessor :list_elements
+ def self.parse(text)
+ todo_list = ToDoList.new
+ todo_list.populate_list_from_text(text)
+ return todo_list
+ end
+
+ def filter common_object
+
+ end
+
+ def adjoin
+ end
+
+ def populate_list_from_text(resource_text)
+ list_elements = []
+ resource_text.each_line do
+ |line| list_elements<< (Task.new).initiate_task(line)
+ end
+ @list_elements = list_elements
+ end
+
+ def tasks_todo
+ return (@list_elements.find_all{|item| item.status == "TODO"}).size
+end
+
+ def tasks_in_progress
+ return (@list_elements.find_all{|item| item.status == "CURRENT"}).size
+ end
+
+ def tasks_completed
+ return (@list_elements.find_all{|item| item.status == "DONE"}).size
+ end
+
+ def completed?
+ return @list_elements.size == tasks_completed
+ end
+end
+
+class Criteria
+ def self.status(passed_status)
+ CommonObject.new(passed_status,[],[],[])
+ end
+
+ def self.priority(passed_priority)
+ CommonObject.new([],[passed_priority],[],[])
+ end
+
+ def self.tags(passed_tags)
+ CommonObject.new([],[],passed_tags,[])
+ end
+end
+
+class CommonObject
+ attr_accessor :statuses, :priorities, :tags, :collection
+ def !
+
+ end
+
+ def &(other_commobj)
+
+ end
+
+ def |(other_comm)
+ @collection<<[other_comm.statuses,other_comm.priorities,other_comm.tags]
+ return self
+ end
+
+ def initialize(stat=[],prior=[],tag=[],coll=[])
+ @statuses, @priorities, @tags, @collection= stat, prior, tag, coll
+ self.collection << [stat,prior,tag]
+ return self
+ end
+end