This means that there will be a short period when only a relatively small percentage
of the label is visible. If you would like, you can modify the ticker to constantly fill
the screen by using two labels (for the sake of this example, that??™s more complexity for
relatively little gain). And if you would prefer a right-to-left scrolling ticker, the following
replacement method does just that:
def scroll_label
if(@tickerlabel.x > @main_window.width)
@tickerlabel.move(-@tickerlabel.width , @tickerlabel.y)
else
@tickerlabel.move(@tickerlabel.x + 3, @tickerlabel.y)
end
end
Next, the get_label_text function takes the list of stock symbols and gets a price for
each of them:
def get_label_text
label_text = ''
YahooFinance::get_standard_quotes( @symbols ).each do |symbol, quote|
label_text << "#{symbol}: #{quote.lastTrade} ... "
end
label_text
end
CHAPTER 9 n INVESTMENT TRACKING WITH FIDELITY 186
This function calls the YahooFinance::get_standard_quotes function, which takes an
array of stock symbols, downloads the current prices from the web site, and returns a
hash where the keys are the stock symbols and the values are the quotes.
Pages:
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270