class Todo::Data::Matcher
Constants
- ATTRS
Attributes
data[R]
item[R]
Public Class Methods
new(item, data)
click to toggle source
# File lib/todo/data/matcher.rb, line 12 def initialize(item, data) @item = item @data = slice(data, *ATTRS) end
Public Instance Methods
matches?()
click to toggle source
# File lib/todo/data/matcher.rb, line 17 def matches? return true if data.empty? data[:id] ? match_id : match_data end
Private Instance Methods
match_after()
click to toggle source
# File lib/todo/data/matcher.rb, line 46 def match_after item.done_date.to_s >= data[:after].to_s end
match_before()
click to toggle source
# File lib/todo/data/matcher.rb, line 50 def match_before item.done_date.to_s < data[:before].to_s end
match_data()
click to toggle source
# File lib/todo/data/matcher.rb, line 24 def match_data data.keys.inject(true) do |result, key| result && send(:"match_#{key}") end end
match_id()
click to toggle source
# File lib/todo/data/matcher.rb, line 30 def match_id item.id.to_i == data[:id].to_i end
match_projects()
click to toggle source
# File lib/todo/data/matcher.rb, line 38 def match_projects item.projects & data[:projects] == data[:projects] end
match_status()
click to toggle source
# File lib/todo/data/matcher.rb, line 42 def match_status item.status && item.status.to_sym == normalize_status(data[:status].to_sym) end
match_text()
click to toggle source
# File lib/todo/data/matcher.rb, line 34 def match_text item.text.include?(data[:text]) unless data[:text].empty? end
normalize_status(status)
click to toggle source
# File lib/todo/data/matcher.rb, line 54 def normalize_status(status) status == :pending ? :pend : status end