Class: Rack::Environmental

Inherits:
Plastic
  • Object
show all
Defined in:
lib/rack-environmental.rb

Instance Method Summary collapse

Instance Method Details

#change_nokogiri_doc(doc) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rack-environmental.rb', line 6

def change_nokogiri_doc(doc)
  initialize_environment_options
  add_to_top_of_web_page(doc, create_sticker(doc))
  add_to_top_of_web_page(doc, create_print_suppression_node(doc))
  if @environment_options[:background]
    body = doc.at_css("body")
    background_style = "background-color: #{@environment_options[:color] || default_color};"
    if body['style']
      body['style'] << ";#{background_style}"
    else
      body['style'] = background_style
    end
  end
  doc
end