Skip to content

Commit feb8569

Browse files
committed
Cleaned up sample 10 a little bit.
1 parent 72b4743 commit feb8569

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

chapter_18/10_a_yahoo_search.rb

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,12 @@ def setup
1313

1414
def draw
1515
background 255
16-
17-
# When a request is finished the available
18-
# flag is set to true - and we get a chance to read
19-
# the data returned by the request
16+
# XXX: There are still issues related to events from imported library
17+
# so we call the search_event method ourselves
18+
# When a request is finished the available flag is set to true
19+
# and we get a chance to read the data returned by the request
2020
if @yahoo.available?
21-
# Get Titles and URLs
22-
titles = @yahoo.get_titles
23-
24-
# Search results arrive as an array of Strings.
25-
# You can also get the summaries with getSummaries().
26-
urls = @yahoo.get_urls
27-
28-
titles.each_with_index do |title, i|
29-
puts "__________"
30-
puts title
31-
puts urls[i]
32-
end
33-
21+
search_event(@yahoo)
3422
no_loop
3523
end
3624
end
@@ -42,18 +30,16 @@ def mouse_pressed
4230
@yahoo.search "processing.org"
4331
end
4432

45-
# XXX: There are still issues related to events from imported library
46-
# so we're not implementing this yet.
47-
#def search_event(yahoo)
48-
# # Get Titles and URLs
49-
# titles = yahoo.get_titles
50-
# # Search results arrive as an array of Strings.
51-
# # You can also get the summaries with getSummaries().
52-
# urls = yahoo.get_urls
53-
#
54-
# titles.each_with_index do |title, i|
55-
# puts "__________"
56-
# puts title
57-
# puts urls[i]
58-
# end
59-
#end
33+
def search_event(yahoo)
34+
# Get Titles and URLs
35+
titles = yahoo.get_titles
36+
# Search results arrive as an array of Strings.
37+
# You can also get the summaries with getSummaries().
38+
urls = yahoo.get_urls
39+
40+
titles.each_with_index do |title, i|
41+
puts "__________"
42+
puts title
43+
puts urls[i]
44+
end
45+
end

0 commit comments

Comments
 (0)