class BestSeats::BestSeatIndexFinder

Constants

DENOMINATOR

Attributes

collection_size[R]

Public Class Methods

new(collection_size) click to toggle source
# File lib/best_seats/best_seat_index_finder.rb, line 7
def initialize(collection_size)
  @collection_size = collection_size
end

Public Instance Methods

call() click to toggle source
# File lib/best_seats/best_seat_index_finder.rb, line 11
def call
  ((middle_position.floor + middle_position.ceil) / DENOMINATOR).to_i
end

Private Instance Methods

middle_position() click to toggle source
# File lib/best_seats/best_seat_index_finder.rb, line 17
def middle_position
  @_middle_position ||= (collection_size - 1) / DENOMINATOR
end