Class: Availabiliter::InputFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/availabiliter/input_formatter.rb

Overview

Convert raw time slots to TimeSlot instances

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_array:, time_zone:) ⇒ InputFormatter

Returns a new instance of InputFormatter.



8
9
10
11
# File 'lib/availabiliter/input_formatter.rb', line 8

def initialize(input_array:, time_zone:)
  @input_array = input_array
  @time_zone = time_zone
end

Instance Attribute Details

#input_arrayObject (readonly)

Returns the value of attribute input_array.



6
7
8
# File 'lib/availabiliter/input_formatter.rb', line 6

def input_array
  @input_array
end

#time_zoneObject (readonly)

Returns the value of attribute time_zone.



6
7
8
# File 'lib/availabiliter/input_formatter.rb', line 6

def time_zone
  @time_zone
end

Instance Method Details

#time_slotsObject



13
14
15
16
17
18
19
20
# File 'lib/availabiliter/input_formatter.rb', line 13

def time_slots
  input_array.map do |time_slot_input|
    validate_time_slot_input(time_slot_input)

    TimeSlot.new(starting_time: to_timestamp(time_slot_input.first),
                 ending_time: to_timestamp(time_slot_input.last))
  end
end