Topic: How to use a class as a temporary table of records in memory
I want a list of court availability times with the following fields.
venue_id, start_time, end_time, just like a table of records.
I want to create new records on a loop and then iterate over the records. What is the best way to do this? It would seem easy if I used the db to store the records but I don't need persistence.
myClass.each do produces a no method error. If I inspect @availability_grid I get only one record, there should be many.
Here is my code so far.
class VenueAvailabilityGrid
attr_accessor :venue_id, :start_time, :end_time, :team_a_played, :team_b_played, :venue_played
def initialize(venue_id, start_time, end_time, team_a_played, team_b_played, venue_played)
@venue_id, @start_time, @end_time, @team_a_played, @team_b_played, @venue_played =
venue_id, start_time, end_time, team_a_played, team_b_played, venue_played
end
end
@availability_grid = VenueAvailabilityGrid.new(venue_id, start_time, end_time, team_a_played, team_b_played, venue_played)