Class: AwesomeMailer::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/awesome_mailer/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_string) ⇒ Renderer

Returns a new instance of Renderer.



5
6
7
8
9
10
11
12
13
# File 'lib/awesome_mailer/renderer.rb', line 5

def initialize(document_string)
  self.document = Nokogiri::HTML.parse(document_string)
  stylesheets = document.search('link[@rel=stylesheet]')
  stylesheets.each do |stylesheet|
    # Must be intended for digital screens!
    load_stylesheet(stylesheet) if stylesheet['media'] =~ /^(all|handheld|screen)$/
  end
  apply_css!(document)
end

Instance Attribute Details

#documentObject

Returns the value of attribute document.



3
4
5
# File 'lib/awesome_mailer/renderer.rb', line 3

def document
  @document
end

Instance Method Details

#to_htmlObject



15
16
17
# File 'lib/awesome_mailer/renderer.rb', line 15

def to_html
  document.to_html
end