Class: Lazylead::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/lazylead/email.rb

Overview

An email regarding tickets based on file with markup.

The ‘tilt’ gem was used as a template engine. Read more about ‘tilt’:

- https://github.com/rtomayko/tilt
- https://github.com/rtomayko/tilt/blob/master/docs/TEMPLATES.md
- https://www.rubyguides.com/2018/11/ruby-erb-haml-slim/
Author

Yurii Dubinka ([email protected])

Copyright

Copyright © 2019-2020 Yurii Dubinka

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(file, binds) ⇒ Email

:file

the file with html template

:binds

the template variables for substitution.



42
43
44
45
# File 'lib/lazylead/email.rb', line 42

def initialize(file, binds)
  @file = file
  @binds = binds
end

Instance Method Details

#renderObject

Construct the email body from html template based on variables (binds).



48
49
50
51
52
# File 'lib/lazylead/email.rb', line 48

def render
  Tilt.new(@file)
      .render(OpenStruct.new(@binds))
      .delete!("\n")
end