Found some Gtk/Ruby signal stuff.

(For gtk2+ruby, I used the Windows installer package)

For some reason, I'm trying to learn a portable language/toolkit.

First, I had to find the correct signal to connect to.  Looks like focus_out_event is it.


currentMileage.signal_connect("focus_out_event") {
  mileagePerDay.text=((targetMileage.text.to_f  - currentMileage.text.to_f)
   /(Time.parse(targetDate.text)-Time.now)*3600*24).to_s
}

signal_connect vs signal_connect_after...  apparently, improper usage of signal_connect (for "focus_out_event") will generate the following warning which the signal occurs
Gtk-WARNING **: GtkEntry - did not receive focus-out-event

From the description, what has happened is a timeout with a now invalid pointer (because of the signal's redirect).  Using signal_connect_after() ensures that the default handler has run first.

currentMileage.signal_connect_after("focus_out_event") {
  mileagePerDay.text=((targetMileage.text.to_f  - currentMileage.text.to_f)
   /(Time.parse(targetDate.text)-Time.now)*3600*24).to_s
}


Next up:  Encapsulate some of this stuff.  In this exercise, I realized that I forgot some of the basics, like how variable scope is defined in Ruby:  http://www.informit.com/articles/article.aspx?p=18225&seqNum=2.

Some additional Ruby links...
Rubyist reference
RubyDocs reference to global variables
6 Ways to Run Shell Commands in Ruby

A better 20 miler than last time

Elevation chart:

Got about a 10 am start, and temps today ended up warming up quite a bit faster than the last few days--no risk of frost this morning either. Still, the temperature was in the low 50s and sunny to start--a little chilly for a sleeveless running shirt. By mile 15, I was happy to have the warmer weather gear on. Did a lot of out and backs, and found a new connection between streets.

Summary Data
Total Time (h:m:s) 3:00:08 8:59 pace
Moving Time (h:m:s) 2:59:47 8:58 pace
Distance (mi ) 20.02
Moving Speed (mph) 6.7 avg. 9.8 max.
Elevation Gain (ft) +1,229 / -1,230
Temperature (°F) 62°F avg. 66.2°F high
Wind Speed ( mph) SE 2.3 avg. SE 3.5 max.

Laps (goal pace was 9'00", so only missed the mark on the last three miles, and held the average pace below 9s).

Lap
(#)
Time
(m:s)
Distance
(mi )
1 8:44 1.00
2 8:22 1.00
3 8:59 1.00
4 8:51 1.00
5 8:53 1.00
6 8:46 1.00
7 8:55 1.00
8 8:38 1.00
9 8:33 1.00
10 8:58 1.00
11 8:58 1.00
12 8:51 1.00
13 8:57 1.00
14 8:48 1.00
15 8:59 1.00
16 8:57 1.00
17 9:00 1.00
18 9:14 1.00
19 10:05 1.00
20 9:53 1.00
21 0:18 0.03