Class: Meetupinator::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/meetupinator/formatter.rb

Overview

Creates a nicely-formatted version of a list of events.

Instance Method Summary collapse

Instance Method Details

#format(events, template_file, output_file) ⇒ Object

[View source]

6
7
8
9
10
11
12
13
# File 'lib/meetupinator/formatter.rb', line 6

def format(events, template_file, output_file)
  template_engine = ERB.new(File.read(template_file))
  parameters = TemplateContext.new(events)
  output = template_engine.result(parameters.template_binding)

  FileUtils.mkdir_p(File.dirname(output_file))
  File.write(output_file, output)
end