Class: VacationRentalsIcalAdapters::IcalConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/vacation_rentals_ical_adapters/ical_converter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ IcalConverter

Returns a new instance of IcalConverter.



9
10
11
# File 'lib/vacation_rentals_ical_adapters/ical_converter.rb', line 9

def initialize(events)
  @events = events
end

Class Method Details

.to_ical(events) ⇒ Object



2
3
4
# File 'lib/vacation_rentals_ical_adapters/ical_converter.rb', line 2

def self.to_ical(events)
  new(events).to_ical
end

Instance Method Details

#to_icalObject



14
15
16
17
18
19
20
# File 'lib/vacation_rentals_ical_adapters/ical_converter.rb', line 14

def to_ical
  [
    ical_beginning,
    events.map { |event| ical_event_from(event) },
    ical_ending,
  ].reject(&:empty?).join("\n")
end