Sha256: 3284260187f108d8e4863ca4609fc88082c304b21b6fc9681a727c25bb996785
Contents?: true
Size: 636 Bytes
Versions: 4
Compression:
Stored size: 636 Bytes
Contents
class TicketSummary attr_accessor :rows def initialize @rows = [] end def row_for_this(show) @rows.find {|row| row.show == show} || (@rows << TicketSummary::Row.new).last end def <<(ticket) row_for_this(ticket.show) << ticket end class TicketSummary::Row attr_accessor :show, :tickets, :ticket_type_hash def initialize @tickets = [] @ticket_type_hash = {} end def <<(ticket) @tickets << ticket @ticket_type_hash[ticket.ticket_type] ||= [] @ticket_type_hash[ticket.ticket_type] << tickets @show = ticket.show self end end end
Version data entries
4 entries across 4 versions & 1 rubygems