Class: Gillbus::V2::Structs::SegmentSeatMap

Inherits:
Base
  • Object
show all
Defined in:
lib/gillbus/v2/structs/segment_seat_map.rb

Instance Attribute Summary

Attributes inherited from Base

#raw_data

Instance Method Summary collapse

Methods inherited from Base

field, from_raw_data, #initialize

Constructor Details

This class inherits a constructor from Gillbus::V2::Structs::Base

Instance Method Details

#floor_seat_map(floor) ⇒ Object

Array of arrays (see result of #format_seats)



15
16
17
18
19
20
21
22
23
# File 'lib/gillbus/v2/structs/segment_seat_map.rb', line 15

def floor_seat_map(floor)
  floor_seats(floor)
    .group_by(&:row)
    .sort_by(&:first)
    .map do |row, row_seats|
      # TODO: reverse order?
      row_seats.sort_by(&:col)
    end
end

#floor_seats(floor) ⇒ Object



10
11
12
# File 'lib/gillbus/v2/structs/segment_seat_map.rb', line 10

def floor_seats(floor)
  seats.select { |seat| seat.floor == floor }
end

#floorsObject



6
7
8
# File 'lib/gillbus/v2/structs/segment_seat_map.rb', line 6

def floors
  @floors ||= seats.map(&:floor).uniq
end

#format_seats(floor:, separator: " ") ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/gillbus/v2/structs/segment_seat_map.rb', line 25

def format_seats(floor:, separator: "  ")
  rows =
    floor_seat_map(floor).map do |row_seats|
      row_seats
        .map { |seat| "%3s" % seat.number }
        .join(separator)
    end
  rows.join("\n")
end