Class: HtmlEmailCreator::EmailVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/html_email_creator/email_version.rb

Instance Method Summary collapse

Constructor Details

#initialize(formatter, output_basename, settings) ⇒ EmailVersion

Returns a new instance of EmailVersion.



3
4
5
6
7
# File 'lib/html_email_creator/email_version.rb', line 3

def initialize(formatter, output_basename, settings)
  @formatter = formatter
  @output_basename = output_basename
  @settings = settings
end

Instance Method Details

#getObject



9
10
11
# File 'lib/html_email_creator/email_version.rb', line 9

def get
  @formatter.format
end

#idObject



13
14
15
# File 'lib/html_email_creator/email_version.rb', line 13

def id
  @formatter.id
end

#saveObject



17
18
19
20
21
22
23
24
25
# File 'lib/html_email_creator/email_version.rb', line 17

def save
  file = File.join(@settings.output_path, "#{@output_basename}.#{@formatter.extension}")
  directory = File.dirname(file)
  FileUtils.mkdir_p(directory) unless File.exists?(directory)
  File.open(file, "w") do |opened_file|
    opened_file.write(get)
  end
  file
end