Class: TicketNetwork::Catalog::Ticket

Inherits:
Base
  • Object
show all
Defined in:
lib/ticket_network/catalog/ticket.rb

Defined Under Namespace

Classes: Parser

Constant Summary collapse

PARKING_REGEX =
/park/i.freeze

Class Method Summary collapse

Methods inherited from Base

action, defaults, get, post, service

Class Method Details

.all(parameters = {}) ⇒ Object



53
54
55
# File 'lib/ticket_network/catalog/ticket.rb', line 53

def all(parameters={})
  fetch(parameters).tickets
end

.find_lot(parking_pass) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/ticket_network/catalog/ticket.rb', line 87

def find_lot(parking_pass)
  if !parking_pass.section.blank? && parking_pass.section !~ PARKING_REGEX
    parking_pass.section
  elsif !parking_pass.row.blank? && parking_pass.row !~ PARKING_REGEX
    parking_pass.row
  end
end

.find_splits(ticket) ⇒ Object



82
83
84
# File 'lib/ticket_network/catalog/ticket.rb', line 82

def find_splits(ticket)
  ticket.splits.first.ints.collect(&:to_i).sort
end

.parking?(ticket) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/ticket_network/catalog/ticket.rb', line 77

def parking?(ticket)
  ticket.section =~ PARKING_REGEX || ticket.row =~ PARKING_REGEX
end

.raw(parameters = {}) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ticket_network/catalog/ticket.rb', line 57

def raw(parameters={})
  all(parameters).collect do |ticket|
    parking = parking?(ticket)

    {
      :ticket_network_id => ticket.id.to_i,
      :price => ticket.actual_price.to_f,
      :quantity => ticket.ticket_quantity.to_i,
      :section => ticket.section.to_s.gsub(/\//, ' / '),
      :row => ticket.row,
      :notes => ticket.notes,
      :splits => find_splits(ticket),
      :general_admission => false,
      :is_mine => ticket.is_mine == 'true',
      :parking_pass => !!parking,
      :lot => parking ? find_lot(ticket) : nil
    }
  end
end