Class: SectionSummary

Inherits:
Object
  • Object
show all
Defined in:
app/models/section_summary.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#availableObject

Returns the value of attribute available.



2
3
4
# File 'app/models/section_summary.rb', line 2

def available
  @available
end

#compedObject

Returns the value of attribute comped.



2
3
4
# File 'app/models/section_summary.rb', line 2

def comped
  @comped
end

#soldObject

Returns the value of attribute sold.



2
3
4
# File 'app/models/section_summary.rb', line 2

def sold
  @sold
end

#totalObject

Returns the value of attribute total.



2
3
4
# File 'app/models/section_summary.rb', line 2

def total
  @total
end

Class Method Details

.for_tickets(tickets = []) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/models/section_summary.rb', line 4

def self.for_tickets(tickets = [])
  summary = SectionSummary.new
  summary.total = tickets.size
  summary.sold = tickets.select{|t| t.sold?}.size
  summary.comped = tickets.select{|t| t.comped?}.size
  summary.available = tickets.select{|t| t.on_sale?}.size
  summary
end

Instance Method Details

#off_saleObject



13
14
15
# File 'app/models/section_summary.rb', line 13

def off_sale
  total - available - sold - comped
end