class BestSeats::SeatGroup
Attributes
sorted_seats[R]
Public Class Methods
new(sorted_seats)
click to toggle source
# File lib/best_seats/seat_group.rb, line 5 def initialize(sorted_seats) @sorted_seats = sorted_seats end
Public Instance Methods
consecutive_values?()
click to toggle source
# File lib/best_seats/seat_group.rb, line 9 def consecutive_values? sorted_seats.delete_if.with_index do |value, index| if collection_end?(index) true else consecutive_value?(value, sorted_seats[index + 1]) end end sorted_seats.empty? end
Private Instance Methods
collection_end?(index)
click to toggle source
# File lib/best_seats/seat_group.rb, line 27 def collection_end?(index) index >= last_index end
consecutive_value?(value, next_value)
click to toggle source
# File lib/best_seats/seat_group.rb, line 23 def consecutive_value?(value, next_value) value.next == next_value end
last_index()
click to toggle source
# File lib/best_seats/seat_group.rb, line 31 def last_index sorted_seats.size - 1 end