Class: BootstrapEmail::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap-email/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, type: :string, options: {}) ⇒ Compiler

Returns a new instance of Compiler.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bootstrap-email/compiler.rb', line 7

def initialize(input, type: :string, options: {})
  self.config = BootstrapEmail::Config.new(options)
  self.type = type
  case type
  when :string
    html = input
  when :file
    html = File.read(input)
  end
  html = add_layout(html)
  build_premailer_doc(html)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def config
  @config
end

#docObject

Returns the value of attribute doc.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def doc
  @doc
end

#premailerObject

Returns the value of attribute premailer.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def premailer
  @premailer
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def type
  @type
end

Instance Method Details

#perform_html_compileObject Also known as: perform_full_compile



31
32
33
34
35
36
37
38
# File 'lib/bootstrap-email/compiler.rb', line 31

def perform_html_compile
  @perform_html_compile ||= begin
    compile_html
    inline_css
    configure_html
    finalize_document
  end
end

#perform_multipart_compileObject



20
21
22
23
24
25
# File 'lib/bootstrap-email/compiler.rb', line 20

def perform_multipart_compile
  @perform_multipart_compile ||= {
    text: perform_text_compile,
    html: perform_html_compile
  }
end

#perform_text_compileObject



27
28
29
# File 'lib/bootstrap-email/compiler.rb', line 27

def perform_text_compile
  @perform_text_compile ||= plain_text
end