Class: Kayak::SearchResults
- Inherits:
-
Object
- Object
- Kayak::SearchResults
show all
- Defined in:
- lib/kayak/search_results.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(session, search_id) ⇒ SearchResults
Returns a new instance of SearchResults.
6
7
8
9
10
|
# File 'lib/kayak/search_results.rb', line 6
def initialize(session, search_id)
@session = session
@id = search_id
reset!
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
57
58
59
60
|
# File 'lib/kayak/search_results.rb', line 57
def method_missing(method, *args, &block)
load! unless loaded?
@results.send(method, *args, &block)
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4
5
6
|
# File 'lib/kayak/search_results.rb', line 4
def id
@id
end
|
Instance Method Details
#===(other) ⇒ Object
Explicitly define === because the instance method removal above doesn’t catch it.
46
47
48
49
|
# File 'lib/kayak/search_results.rb', line 46
def ===(other)
load!
other === @results
end
|
#complete? ⇒ Boolean
25
26
27
|
# File 'lib/kayak/search_results.rb', line 25
def complete?
@complete
end
|
#inspect ⇒ Object
51
52
53
|
# File 'lib/kayak/search_results.rb', line 51
def inspect
@results.inspect
end
|
#load!(count = nil) ⇒ Object
12
13
14
15
|
# File 'lib/kayak/search_results.rb', line 12
def load!(count = nil)
params = {:searchid => @id, :apimode => 1, :_sid_ => @session.id, :c => count}
load_results @session.get("/s/apibasic/flight", params)
end
|
#loaded! ⇒ Object
21
22
23
|
# File 'lib/kayak/search_results.rb', line 21
def loaded!
@loaded = true
end
|
#loaded? ⇒ Boolean
17
18
19
|
# File 'lib/kayak/search_results.rb', line 17
def loaded?
@loaded
end
|
#reload! ⇒ Object
35
36
37
38
|
# File 'lib/kayak/search_results.rb', line 35
def reload!
reset!
load!
end
|
#reset! ⇒ Object
29
30
31
32
33
|
# File 'lib/kayak/search_results.rb', line 29
def reset!
@loaded = false
@complete = false
@results = []
end
|
#respond_to?(symbol, include_priv = false) ⇒ Boolean
40
41
42
|
# File 'lib/kayak/search_results.rb', line 40
def respond_to?(symbol, include_priv = false)
@results.respond_to?(symbol, include_priv)
end
|