Решение на Втора задача от Милен Мавров

Обратно към всички решения

Към профила на Милен Мавров

Резултати

  • 0 точки от тестове
  • 0 бонус точки
  • 0 точки общо
  • 0 успешни тест(а)
  • 22 неуспешни тест(а)

Код

class Task
attr_reader :description
def status
return :todo if @status == "TODO"
return :current if @status == "CURRENT"
return :done if @status == "DONE"
end
def priority
return :low if @priority == "Low"
return :normal if @priority == "Normal"
return :high if @priority == "High"
end
def tags
@tags == nil ? "" : @tags.split(',')#.map { |e| e.strip }
end
def initialize(task_string)
@status = task_string.split('|')[0].strip
@description = task_string.split('|')[1].strip
@priority = task_string.split('|')[2].strip
@tags = task_string.split('|')[3]
end
end
class TodoList
attr_accessor :the_list
def self.parse(todo_string)
@todo_object = TodoList.new
@todo_object.fillList todo_string
@todo_object
end
def fillList(fill_with)
@the_list = []
fill_with.split(/\n/).each do |str_task|
task = Task.new str_task
@the_list << task
end
end
def filter(array_of_criteria)
filtered_list = TodoListActions.new(@the_list, array_of_criteria)
filtered_list.filter
end
def adjoin
end
def tasks_in_progress
end
def tasks_completed
end
def tasks_todo
end
def completed?
end
end
class TodoListActions
attr_accessor :todo_list, :criterias
def initialize(todo_list_target, array_of_criteria)
@todo_list = todo_list_target
@criteria = array_of_criterias
end
def filter
@criteria.each { |elem| }
end
end
class Criterion
attr_accessor :criterion_status, :criterion_priority, :list_of_criteria
def initialize(c_type, c_concrete)
self.init(c_type, c_concrete)
@list_of_criteria = []
end
def init(c_type, c_concrete)
@criterion_status = c_concrete if c_type == :criterion_status
@criterion_priority = c_concrete if c_type == :criterion_priority
@criterion_tags = c_concrete if c_type == :criterion_tags
end
def criterion_tags
@criterion_tags.split(' ')
end
def criterion_tags=(other)
@criterion_tags = other
end
def getCriteria
return @criterion_status if @criterion_status != nil
return @criterion_priority if @criterion_priority != nil
return @criterion_tags if @criterion_tags != nil
end
def &(other)
@list_of_criteria << 'AND'
other.list_of_criteria.each { |criterion| @list_of_criteria << criterion }
self
end
def |(other)
@list_of_criteria << 'OR'
other.list_of_criteria.each { |criterion| @list_of_criteria << criterion }
self
end
def !@
@list_of_criteria.insert(0, 'NOT')
self
end
end
class Criteria < Criterion
def self.status(target_status)
crit = Criterion.new(:criterion_status, target_status)
crit.list_of_criteria << crit.getCriteria
crit
end
def self.priority(target_priority)
crit = Criterion.new(:criterion_priority, target_priority)
crit.list_of_criteria << crit.getCriteria
crit
end
def self.tags(target_tags)
crit = Criterion.new(:criterion_tags, target_tags)
crit.list_of_criteria << crit.getCriteria
crit
end
end

Лог от изпълнението

FFFFFFFFFFFFFFFFFFFFFF

Failures:

  1) TodoList filters tasks by status
     Failure/Error: todo_list.filter(Criteria.status :done).map(&:description).should =~ [
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9c1c4d8>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:19:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) TodoList filters tasks by priority
     Failure/Error: todo_list.filter(Criteria.priority :high).map(&:description).should =~ [
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9c19c38>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:26:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) TodoList filters tasks by tag
     Failure/Error: todo_list.filter(Criteria.tags %w[food]).map(&:description).should =~ ['Eat spaghetti.']
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9bab1fc>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:36:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) TodoList filters tasks by multiple tags
     Failure/Error: todo_list.filter(Criteria.tags %w[development ruby]).map(&:description).should =~ [
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9ba8740>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:40:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) TodoList filtering by multiple tags matches only tasks with all the tags
     Failure/Error: todo_list.filter(Criteria.tags %w[development FMI]).map(&:description).should =~ ['Do the 5th Ruby challenge.']
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9b981c4>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:47:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) TodoList supports a conjuction of filters
     Failure/Error: filtered = todo_list.filter Criteria.status(:todo) & Criteria.priority(:high)
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9c09220>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:51:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) TodoList supports a disjunction of filters
     Failure/Error: filtered = todo_list.filter Criteria.status(:done) | Criteria.priority(:low)
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9bbe5e0>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:56:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) TodoList supports a negation of filters
     Failure/Error: filtered = todo_list.filter !Criteria.status(:todo)
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a931c0>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:66:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) TodoList supports simple filters combination
     Failure/Error: filtered = todo_list.filter Criteria.priority(:high) & !Criteria.tags(['development'])
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a8fef8>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:76:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) TodoList supports complex filters combination
     Failure/Error: filtered = todo_list.filter Criteria.status(:todo) &
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a8cf28>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:81:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  11) TodoList can be adjoined with another to-do list
     Failure/Error: development = todo_list.filter Criteria.tags(['development'])
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a85c64>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:97:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  12) TodoList constructs an object for each task
     Failure/Error: task = todo_list.filter(Criteria.tags ['health']).first
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a82dfc>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:110:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  13) TodoList returns the number of the tasks todo
     Failure/Error: todo_list.tasks_todo.should eq 5
       
       expected: 5
            got: nil
       
       (compared using ==)
     # /tmp/d20131107-4393-xno9vw/spec.rb:119:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  14) TodoList returns the number of the tasks in progress
     Failure/Error: todo_list.tasks_in_progress.should eq 2
       
       expected: 2
            got: nil
       
       (compared using ==)
     # /tmp/d20131107-4393-xno9vw/spec.rb:123:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  15) TodoList returns the number of the completed tasks
     Failure/Error: todo_list.tasks_completed.should eq 2
       
       expected: 2
            got: nil
       
       (compared using ==)
     # /tmp/d20131107-4393-xno9vw/spec.rb:127:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  16) TodoList checks if all tasks are completed
     Failure/Error: todo_list.completed?.should eq false
       
       expected: false
            got: nil
       
       (compared using ==)
     # /tmp/d20131107-4393-xno9vw/spec.rb:131:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  17) TodoList doesn't modify the to-do list when filtering
     Failure/Error: todo_list.filter(Criteria.status :todo)
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a6791c>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:136:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  18) TodoList implements Enumerable
     Failure/Error: todo_list.should respond_to :each
       expected #<TodoList:0xb9a66cd8 @the_list=[#<Task:0xb9a66bac @status="TODO", @description="Eat spaghetti.", @priority="High", @tags=" food, happiness">, #<Task:0xb9a668b4 @status="TODO", @description="Get 8 hours of sleep.", @priority="Low", @tags=" health">, #<Task:0xb9a66620 @status="CURRENT", @description="Party animal.", @priority="Normal", @tags=" socialization">, #<Task:0xb9a66288 @status="CURRENT", @description="Grok Ruby.", @priority="High", @tags=" development, ruby">, #<Task:0xb9a65f04 @status="DONE", @description="Have some tea.", @priority="Normal", @tags=nil>, #<Task:0xb9a65cac @status="TODO", @description="Destroy Facebook and Google.", @priority="High", @tags=" save humanity, conspiracy">, #<Task:0xb9a659a0 @status="DONE", @description="Do the 5th Ruby challenge.", @priority="High", @tags=" ruby course, FMI, development, ruby">, #<Task:0xb9a655e0 @status="TODO", @description="Find missing socks.", @priority="Low", @tags=nil>, #<Task:0xb9a6534c @status="TODO", @description="Occupy Sofia University.", @priority="High", @tags=" #ДАНСwithMe, #occupysu, #оставка">]> to respond to :each
     # /tmp/d20131107-4393-xno9vw/spec.rb:141:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  19) TodoList contains tasks with the neccessary interface
     Failure/Error: task = todo_list.first
     NoMethodError:
       undefined method `first' for #<TodoList:0xb9a608b0>
     # /tmp/d20131107-4393-xno9vw/spec.rb:146:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  20) TodoList tasks have an array of tags
     Failure/Error: todo_list.first.tags.should be_an Array
     NoMethodError:
       undefined method `first' for #<TodoList:0xb9a5396c>
     # /tmp/d20131107-4393-xno9vw/spec.rb:155:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  21) TodoList preserves the order of tasks
     Failure/Error: todo_list.map(&:description).should eq [
     NoMethodError:
       undefined method `map' for #<TodoList:0xb9a45aec>
     # /tmp/d20131107-4393-xno9vw/spec.rb:159:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  22) TodoList creates a new object on filter
     Failure/Error: todo_list.filter(Criteria.tags %w[wtf]).should_not equal todo_list
     NameError:
       undefined local variable or method `array_of_criterias' for #<TodoListActions:0xb9a0f03c>
     # /tmp/d20131107-4393-xno9vw/solution.rb:70:in `initialize'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `new'
     # /tmp/d20131107-4393-xno9vw/solution.rb:46:in `filter'
     # /tmp/d20131107-4393-xno9vw/spec.rb:173:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.02771 seconds
22 examples, 22 failures

Failed examples:

rspec /tmp/d20131107-4393-xno9vw/spec.rb:18 # TodoList filters tasks by status
rspec /tmp/d20131107-4393-xno9vw/spec.rb:25 # TodoList filters tasks by priority
rspec /tmp/d20131107-4393-xno9vw/spec.rb:35 # TodoList filters tasks by tag
rspec /tmp/d20131107-4393-xno9vw/spec.rb:39 # TodoList filters tasks by multiple tags
rspec /tmp/d20131107-4393-xno9vw/spec.rb:46 # TodoList filtering by multiple tags matches only tasks with all the tags
rspec /tmp/d20131107-4393-xno9vw/spec.rb:50 # TodoList supports a conjuction of filters
rspec /tmp/d20131107-4393-xno9vw/spec.rb:55 # TodoList supports a disjunction of filters
rspec /tmp/d20131107-4393-xno9vw/spec.rb:65 # TodoList supports a negation of filters
rspec /tmp/d20131107-4393-xno9vw/spec.rb:75 # TodoList supports simple filters combination
rspec /tmp/d20131107-4393-xno9vw/spec.rb:80 # TodoList supports complex filters combination
rspec /tmp/d20131107-4393-xno9vw/spec.rb:96 # TodoList can be adjoined with another to-do list
rspec /tmp/d20131107-4393-xno9vw/spec.rb:109 # TodoList constructs an object for each task
rspec /tmp/d20131107-4393-xno9vw/spec.rb:118 # TodoList returns the number of the tasks todo
rspec /tmp/d20131107-4393-xno9vw/spec.rb:122 # TodoList returns the number of the tasks in progress
rspec /tmp/d20131107-4393-xno9vw/spec.rb:126 # TodoList returns the number of the completed tasks
rspec /tmp/d20131107-4393-xno9vw/spec.rb:130 # TodoList checks if all tasks are completed
rspec /tmp/d20131107-4393-xno9vw/spec.rb:135 # TodoList doesn't modify the to-do list when filtering
rspec /tmp/d20131107-4393-xno9vw/spec.rb:140 # TodoList implements Enumerable
rspec /tmp/d20131107-4393-xno9vw/spec.rb:145 # TodoList contains tasks with the neccessary interface
rspec /tmp/d20131107-4393-xno9vw/spec.rb:154 # TodoList tasks have an array of tags
rspec /tmp/d20131107-4393-xno9vw/spec.rb:158 # TodoList preserves the order of tasks
rspec /tmp/d20131107-4393-xno9vw/spec.rb:172 # TodoList creates a new object on filter

История (1 версия и 0 коментара)

Милен обнови решението на 06.11.2013 04:10 (преди над 10 години)

+class Task
+ attr_reader :description
+
+ def status
+ return :todo if @status == "TODO"
+ return :current if @status == "CURRENT"
+ return :done if @status == "DONE"
+ end
+
+ def priority
+ return :low if @priority == "Low"
+ return :normal if @priority == "Normal"
+ return :high if @priority == "High"
+ end
+
+ def tags
+ @tags == nil ? "" : @tags.split(',')#.map { |e| e.strip }
+ end
+
+ def initialize(task_string)
+ @status = task_string.split('|')[0].strip
+ @description = task_string.split('|')[1].strip
+ @priority = task_string.split('|')[2].strip
+ @tags = task_string.split('|')[3]
+ end
+end
+
+class TodoList
+ attr_accessor :the_list
+
+ def self.parse(todo_string)
+ @todo_object = TodoList.new
+ @todo_object.fillList todo_string
+ @todo_object
+ end
+
+ def fillList(fill_with)
+ @the_list = []
+ fill_with.split(/\n/).each do |str_task|
+ task = Task.new str_task
+ @the_list << task
+ end
+ end
+
+ def filter(array_of_criteria)
+ filtered_list = TodoListActions.new(@the_list, array_of_criteria)
+ filtered_list.filter
+ end
+
+ def adjoin
+ end
+
+ def tasks_in_progress
+ end
+
+ def tasks_completed
+ end
+
+ def tasks_todo
+ end
+
+ def completed?
+ end
+end
+
+class TodoListActions
+ attr_accessor :todo_list, :criterias
+ def initialize(todo_list_target, array_of_criteria)
+ @todo_list = todo_list_target
+ @criteria = array_of_criterias
+ end
+
+ def filter
+ @criteria.each { |elem| }
+ end
+end
+
+class Criterion
+ attr_accessor :criterion_status, :criterion_priority, :list_of_criteria
+
+ def initialize(c_type, c_concrete)
+ self.init(c_type, c_concrete)
+ @list_of_criteria = []
+ end
+
+ def init(c_type, c_concrete)
+ @criterion_status = c_concrete if c_type == :criterion_status
+ @criterion_priority = c_concrete if c_type == :criterion_priority
+ @criterion_tags = c_concrete if c_type == :criterion_tags
+ end
+
+ def criterion_tags
+ @criterion_tags.split(' ')
+ end
+
+ def criterion_tags=(other)
+ @criterion_tags = other
+ end
+
+ def getCriteria
+ return @criterion_status if @criterion_status != nil
+ return @criterion_priority if @criterion_priority != nil
+ return @criterion_tags if @criterion_tags != nil
+ end
+
+ def &(other)
+ @list_of_criteria << 'AND'
+ other.list_of_criteria.each { |criterion| @list_of_criteria << criterion }
+ self
+ end
+
+ def |(other)
+ @list_of_criteria << 'OR'
+ other.list_of_criteria.each { |criterion| @list_of_criteria << criterion }
+ self
+ end
+
+ def !@
+ @list_of_criteria.insert(0, 'NOT')
+ self
+ end
+end
+
+class Criteria < Criterion
+
+ def self.status(target_status)
+ crit = Criterion.new(:criterion_status, target_status)
+ crit.list_of_criteria << crit.getCriteria
+ crit
+ end
+
+ def self.priority(target_priority)
+ crit = Criterion.new(:criterion_priority, target_priority)
+ crit.list_of_criteria << crit.getCriteria
+ crit
+ end
+
+ def self.tags(target_tags)
+ crit = Criterion.new(:criterion_tags, target_tags)
+ crit.list_of_criteria << crit.getCriteria
+ crit
+ end
+end