54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/pismo.rb', line 54
def match(queries = [], all = false)
r = [] if all
[*queries].each do |query|
if query.is_a?(String)
if el = self.search(query).first
if el.name.downcase == "meta"
result = el['content'].strip rescue nil
else
result = el.inner_text.strip rescue nil
end
end
elsif query.is_a?(Array)
result = query[1].call(self.search(query.first).first).strip rescue nil
end
if result
result.gsub!('’', '\'')
result.gsub!('—', '-')
if all
r << result
else
return result
end
end
end
all && !r.empty? ? r : nil
end
|