Class: DailyTicketReport::Row

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

Direct Known Subclasses

ExchangeRow

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ Row

Returns a new instance of Row.



41
42
43
44
45
46
47
48
49
# File 'app/models/daily_ticket_report.rb', line 41

def initialize(order)
  @order = order
  @id = order.id
  @ticket_details = create_ticket_details
  @total = calculate_total
  @person = order.person
  @person_id = order.person.id
  @special_instructions = order.special_instructions
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def id
  @id
end

#orderObject

Returns the value of attribute order.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def order
  @order
end

#personObject

Returns the value of attribute person.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def person
  @person
end

#person_idObject

Returns the value of attribute person_id.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def person_id
  @person_id
end

#special_instructionsObject

Returns the value of attribute special_instructions.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def special_instructions
  @special_instructions
end

#ticket_detailsObject

Returns the value of attribute ticket_details.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def ticket_details
  @ticket_details
end

#totalObject

Returns the value of attribute total.



40
41
42
# File 'app/models/daily_ticket_report.rb', line 40

def total
  @total
end

Instance Method Details

#calculate_totalObject



55
56
57
# File 'app/models/daily_ticket_report.rb', line 55

def calculate_total
  DailyTicketReport.number_to_currency(@order.tickets.reject(&:exchanged?).sum(&:price).to_f/100)
end

#create_ticket_detailsObject



51
52
53
# File 'app/models/daily_ticket_report.rb', line 51

def create_ticket_details
  @order.ticket_details
end

#to_aObject



59
60
61
# File 'app/models/daily_ticket_report.rb', line 59

def to_a
  [id, total, person, ticket_details, special_instructions]
end