class MoreHoliday::Exporter

Attributes

content[R]

Public Class Methods

new(content) click to toggle source
# File lib/more_holiday/exporter.rb, line 8
def initialize content
  @content = content
end

Public Instance Methods

to_file(path, type: "ical") click to toggle source
# File lib/more_holiday/exporter.rb, line 12
def to_file path, type: "ical"
  output_base_path = path || Dir.pwd
  data, extension = serialize(type)
  complete_path = File.join(output_base_path, "MoreHoliday.#{extension}")
  FileUtils.mkdir_p(output_base_path)
  File.write(complete_path, data)
  complete_path
end
to_stream(type) click to toggle source
# File lib/more_holiday/exporter.rb, line 21
def to_stream type
  serialize(type).first
end

Private Instance Methods

serialize(type) click to toggle source
# File lib/more_holiday/exporter.rb, line 27
def serialize type
  case type
  when "ical" then [Exporters::ICal.new(content).serialize, "ics"]
  else raise NotSupportedError, "Type of file is not supported."
  end
end