@@ -12,8 +12,8 @@ def setup
1212
1313 # Create and make an asynchronous request using
1414 # the Request object from the library
15- @htmlRequest = HTMLRequest . new ( self , "http://www.yahoo.com" )
16- @htmlRequest . makeRequest
15+ @request = HTMLRequest . new ( self , "http://www.yahoo.com" )
16+ @request . makeRequest
1717 @timer = Timer . new ( 5000 )
1818 @timer . start
1919 background 0
@@ -25,7 +25,7 @@ def draw
2525 # A request is made every 5s.
2626 # The data is not received here, however, this is only the request.
2727 if @timer . finished?
28- @htmlRequest . makeRequest
28+ @request . make_request
2929 # XXX: was println("Making request!");
3030 puts "Making request!"
3131 @timer . start
@@ -34,10 +34,10 @@ def draw
3434 # When a request is finished the data the available
3535 # flag is set to true - and we get a chance to read
3636 # the data returned by the request
37- if @htmlRequest . available?
38- @html = @htmlRequest . readRawSource # Read the raw data
39- @back = 255 # Reset background
40- puts "Request completed!" # Print message
37+ if @request . available?
38+ @html = @request . read_raw_source # Read the raw data
39+ @back = 255 # Reset background
40+ puts "Request completed!" # Print message
4141 end
4242
4343 # Draw some lines with colors based on characters from data retrieved
@@ -72,23 +72,23 @@ def draw
7272# Timer Class from Chapter 10
7373#
7474class Timer
75- def initialize ( tempTotalTime )
76- @totalTime = tempTotalTime
77- @running = false
75+ def initialize ( total_time )
76+ @total_time = total_time
77+ @running = false
7878 end
7979
8080 def start
81- @running = true
82- @savedTime = $app. millis
81+ @running = true
82+ @saved_time = $app. millis
8383 end
8484
8585 def finished?
86- passedTime = $app. millis - @savedTime
87- if @running && ( passedTime > @totalTime )
86+ finished = $app. millis - @saved_time > @total_time
87+ if @running && finished
8888 @running = false
89- return true ;
89+ return true
9090 else
91- return false ;
91+ return false
9292 end
9393 end
9494end
0 commit comments