Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (33 sloc) 790 Bytes
module EasterEggs
class Search
class << self
def perform(query)
reference = references.find do |_universe, list|
list.any? { |regex| regex =~ query.downcase }
end&.first
return if reference.nil?
{
reference: reference,
message: EasterEggs::Universe.t(reference)
}
end
private
def references
{
EasterEggs::Universe::STAR_WARS => [
/star wars/,
/force awakens/,
/rogue one/
],
EasterEggs::Universe::SUPER_MARIO => [
/super mario/
],
EasterEggs::Universe::BREAKING_BAD => [
/breaking bad/,
/walter white/
]
}
end
end
end
end