Sha256: 2b4dcb50b14ec27215ade306b271233cf57feaa9391fd54561c7dd6649315523

Contents?: true

Size: 698 Bytes

Versions: 14

Compression:

Stored size: 698 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
      if @ticket_type_hash[ticket.ticket_type].nil?
        @ticket_type_hash[ticket.ticket_type] = []
      end

      @ticket_type_hash[ticket.ticket_type] << ticket
      @show = ticket.show
      self
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/models/ticket_summary.rb
artfully_ose-1.2.0.beta.1 app/models/ticket_summary.rb
artfully_ose-1.2.0.alpha.2 app/models/ticket_summary.rb
artfully_ose-1.2.0.alpha.1 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.27 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.26 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.24 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.23 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.21 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.20 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.19 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.18 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.17 app/models/ticket_summary.rb
artfully_ose-1.2.0.pre.16 app/models/ticket_summary.rb