5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/doing/helpers.rb', line 5
def has_tags?(tags, bool = :and)
tags = tags.split(/ *, */) if tags.is_a? String
bool = bool.normalize_bool if bool.is_a? String
item = self
tags.map! {|t| t.strip.sub(/^@/, '')}
case bool
when :and
result = true
tags.each do |tag|
unless item['title'] =~ /@#{tag}/
result = false
break
end
end
result
when :not
result = true
tags.each do |tag|
if item['title'] =~ /@#{tag}/
result = false
break
end
end
result
else
result = false
tags.each do |tag|
if item['title'] =~ /@#{tag}/
result = true
break
end
end
result
end
end
|