From: Howard R. [mailto:[email protected]]
some sample data and pseudo code is here:
The output I’m trying to achieve would look like the
following, listing
first the date, then the information all of the first objects
, and then
all of the second objects for that date:
7/18/08
9:00 AM - Orientation
Location: Conference Room
Welcome, review agenda, and brief Q&A
7:30 AM - First Event
The Smiths invite you for a casual breakfast at Grumpy’s
7/19/08
8:00 AM - Workshop I
Location: Room 106
Boring, all day presentation by Dr. Jones
#…
ok, that is much clearer and complete.
i just modified your last code loop as,
#—code
prev_date=nil
@data.sort_by do |item|
t,ampm = item.time.split
hr,min = t.split “:”
hr = “0”+hr if hr.size==1
timenew = ampm+hr+min
[item.date, timenew, item.class.to_s]
end.each do |item|
puts “#{item.date.strftime(‘%m/%d/%y’)}\n\n” if prev_date != item.date
if item.is_a? Meeting
puts “#{item.time} - #{item.activity}\n”
puts “Location: #{item.location}\n”
puts “#{item.description}\n\n”
else
puts “#{item.time} - #{item.name}\n”
puts “#{item.attendees} invite you for a #{item.mood}
#{item.activity} at #{item.location}\n\n”
end
prev_date = item.date
end
#—code
There’s some clobbering of time in there since i arranged by time too
So the output is,
C:\family\ruby>ruby test.rb
07/18/08
7:30 AM - First event
The Smiths invite you for a casual Breakfast at Grumpy’s
9:00 AM - Orientation
Location: Conference Room
Welcome, review agenda, and brief Q&A
07/19/08
8:00 AM - Workshop I
Location: Room 106
Boring, all day presentation by Dr. Jones
07/20/08
6:00 PM - Second event
The Jones invite you for a Sociable Dinner at La Nepolara’s
07/21/08
7:30 AM - Third event
the Smiths invite you for a casual Breakfast at Mel’s
8:00 AM - Workshop II
Location: Room 108
Yet another boring, all day presentation by Dr. Jones
1:00 PM - Third event
Dr. Jones and Staff invite you for a Business Lunch at The Krusty Krab
2:30 PM - Wrap-Up
Location: Room 108
Summary, Q&A, and lots of free goodies
C:\family\ruby>
Is that ok?
Kind regards -botp