Class: Availabiliter::OutputFormatter

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

Overview

Transform availabilities to the required format

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(availabilities, format:, time_zone:) ⇒ OutputFormatter

Returns a new instance of OutputFormatter.



6
7
8
9
10
# File 'lib/availabiliter/output_formatter.rb', line 6

def initialize(availabilities, format:, time_zone:)
  @availabilities = availabilities
  @format = format
  @time_zone = time_zone
end

Instance Attribute Details

#availabilitiesObject (readonly)

Returns the value of attribute availabilities.



4
5
6
# File 'lib/availabiliter/output_formatter.rb', line 4

def availabilities
  @availabilities
end

#formatObject (readonly)

Returns the value of attribute format.



4
5
6
# File 'lib/availabiliter/output_formatter.rb', line 4

def format
  @format
end

#time_zoneObject (readonly)

Returns the value of attribute time_zone.



4
5
6
# File 'lib/availabiliter/output_formatter.rb', line 4

def time_zone
  @time_zone
end

Instance Method Details

#format_availabilitiesObject



12
13
14
15
16
# File 'lib/availabiliter/output_formatter.rb', line 12

def format_availabilities
  availabilities.map do |availability|
    convert_to_format(availability)
  end
end