Class: HtmlEmailCreator::Email
- Inherits:
-
Object
- Object
- HtmlEmailCreator::Email
- Defined in:
- lib/html_email_creator/email.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(configuration, settings = HtmlEmailCreator.settings) ⇒ Email
constructor
A new instance of Email.
-
#render_all ⇒ Object
Renders emails using configuration.
-
#render_html_email ⇒ Object
Convenience method for rendering HTML email.
-
#render_only(format) ⇒ Object
Renders email in a specific format.
-
#render_plain_text_email ⇒ Object
Convenience method for rendering plain text email.
Constructor Details
#initialize(configuration, settings = HtmlEmailCreator.settings) ⇒ Email
Returns a new instance of Email.
21 22 23 24 |
# File 'lib/html_email_creator/email.rb', line 21 def initialize(configuration, settings = HtmlEmailCreator.settings) @settings = settings @configuration = create_configuration(configuration) end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
6 7 8 |
# File 'lib/html_email_creator/email.rb', line 6 def settings @settings end |
Class Method Details
.find_emails(file_or_directory, recursively = false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/html_email_creator/email.rb', line 8 def self.find_emails(file_or_directory, recursively = false) if File.directory?(file_or_directory) if recursively Dir.glob(File.join(file_or_directory, "**", "*.yaml")) else Dir.glob(File.join(file_or_directory, "*.yaml")) end else return [] unless File.extname(file_or_directory) == ".yaml" [file_or_directory] end end |
Instance Method Details
#render_all ⇒ Object
Renders emails using configuration. Returns Hash[format, EmailVersion].
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/html_email_creator/email.rb', line 27 def render_all # render only once return @versions if @versions @versions = {} output_formats.each do |format| @versions[format] = render_only(format) end @versions end |
#render_html_email ⇒ Object
Convenience method for rendering HTML email.
45 46 47 |
# File 'lib/html_email_creator/email.rb', line 45 def render_html_email render_only(HtmlEmailCreator::Formatters::HtmlEmail.id) end |
#render_only(format) ⇒ Object
Renders email in a specific format
39 40 41 42 |
# File 'lib/html_email_creator/email.rb', line 39 def render_only(format) formatter = HtmlEmailCreator::Formatter.new(rendered_email, @settings).find(format) HtmlEmailCreator::EmailVersion.new(formatter, output_basename, @settings) end |
#render_plain_text_email ⇒ Object
Convenience method for rendering plain text email.
50 51 52 |
# File 'lib/html_email_creator/email.rb', line 50 def render_plain_text_email render_only(HtmlEmailCreator::Formatters::PlainTextEmail.id) end |