16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/teecket.rb', line 16
def self.search(params)
flights = [
"AirAsia",
"Firefly",
"MalaysiaAirlines",
"MalindoAir"
]
results = []
threads = []
flights.each do |flight|
threads << Thread.new do
klass = Object.const_get(flight)
scrapper = klass.new(from: params[:from],
to: params[:to],
date: params[:date])
scrapper.search
results = results + scrapper.fares
end
end
ThreadsWait.all_waits(*threads)
results
end
|