Module: CalendarAssistant::PredicateCollection

Defined in:
lib/calendar_assistant/predicate_collection.rb

Class Method Summary collapse

Class Method Details

.build(must_be, must_not_be) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/calendar_assistant/predicate_collection.rb', line 3

def self.build(must_be, must_not_be)
  predicates = {}
  Array(must_be).each do |predicate|
    predicates[predicate_symbol(predicate)] = true
  end

  Array(must_not_be).each do |predicate|
    predicates[predicate_symbol(predicate)] = false
  end

  predicates
end

.predicate_symbol(str) ⇒ Object



16
17
18
# File 'lib/calendar_assistant/predicate_collection.rb', line 16

def self.predicate_symbol(str)
  str.to_s.gsub(/(.*[^?])$/, "\\1?").to_sym
end