Prev | Current Page 242 | Next

David Berube

"Practical Reporting with Ruby and Rails"

new( interface, port)
mongrel_server.register("/", StocksListHandler.new(stocks_list))
puts "** Fidelity XML server started on #{interface}:#{port}!"
mongrel_server.run.join
Save this file as xml_server.rb.
You can run the example as follows:
ruby xml_server.rb example_fidelity.csv
Note that if you have multiple accounts with Fidelity, you can run this script with
multiple files, as follows:
ruby xml_server.rb first_csv_file.csv second_csv_file.csv ...
This script is meant to be used in conjunction with the graphical ticker (shown later
in Listing 9-2), but for now, you can see the output in a web browser by visiting the following
URL:
http://127.0.0.1:3000/
You should see output similar to that shown in Figure 9-1.
CHAPTER 9 n INVESTMENT TRACKING WITH FIDELITY 175
Figure 9-1. XML stock symbol server in action
Let??™s take a look at a few lines from this example.
Dissecting the Code
The code in Listing 9-1 has two classes:
??? StocksList: This class maintains the list of stock symbols that you will serve as
XML.


Pages:
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
Poker Porady przeprowadzki katowice Cd Poker Titan Poker Dyskusja Nr10