Class: UndriveGoogle::Transformations::FixHtml
- Inherits:
-
Object
- Object
- UndriveGoogle::Transformations::FixHtml
- Extended by:
- Forwardable
- Defined in:
- lib/undrive_google/transformations/fix_html.rb
Overview
In Google Doc generated HTML, optionally replace:
<html><head>
with
<html lang="en"><head><title>Peter Boling's Bounce to the Ounce</title>
Instance Attribute Summary collapse
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#title ⇒ Object
Returns the value of attribute title.
-
#unzip ⇒ Object
Returns the value of attribute unzip.
Instance Method Summary collapse
-
#initialize(unzip) ⇒ FixHtml
constructor
A new instance of FixHtml.
-
#process ⇒ Object
Nil.
Constructor Details
Instance Attribute Details
#lang ⇒ Object
Returns the value of attribute lang.
16 17 18 |
# File 'lib/undrive_google/transformations/fix_html.rb', line 16 def lang @lang end |
#title ⇒ Object
Returns the value of attribute title.
16 17 18 |
# File 'lib/undrive_google/transformations/fix_html.rb', line 16 def title @title end |
#unzip ⇒ Object
Returns the value of attribute unzip.
16 17 18 |
# File 'lib/undrive_google/transformations/fix_html.rb', line 16 def unzip @unzip end |
Instance Method Details
#process ⇒ Object
Returns nil.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/undrive_google/transformations/fix_html.rb', line 27 def process return unless lang || title puts "Checking html in #{html_path}" if Options.instance.verbose file = File.open(html_path) html = file.read return unless html puts "Fixing html in #{html_path}" if Options.instance.verbose html.sub!("<html>", "<html lang=\"#{lang}\">") if lang html.sub!("<head>", "<head><title>#{title}</title>") if title File.write(html_path, html) nil end |