Class: BookChef::Compiler::HTML
- Inherits:
-
Object
- Object
- BookChef::Compiler::HTML
- Defined in:
- lib/bookchef/compilers/html.rb
Overview
Converts XML into HTML using xslt
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(fn, xslt_stylesheet = "#{BookChef::LIB_PATH}/stylesheets/xslt/bookchef_to_html.xsl") ⇒ HTML
constructor
A new instance of HTML.
- #run ⇒ Object
- #save_to(fn) ⇒ Object
Constructor Details
#initialize(fn, xslt_stylesheet = "#{BookChef::LIB_PATH}/stylesheets/xslt/bookchef_to_html.xsl") ⇒ HTML
Returns a new instance of HTML.
9 10 11 12 13 14 |
# File 'lib/bookchef/compilers/html.rb', line 9 def initialize(fn, xslt_stylesheet="#{BookChef::LIB_PATH}/stylesheets/xslt/bookchef_to_html.xsl") xslt_stylesheet = File.read(xslt_stylesheet).sub('#{gem_path}', "file://#{BookChef::LIB_PATH}") @document = XML::XSLT.new @document.xml = fn @document.xsl = xslt_stylesheet end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
7 8 9 |
# File 'lib/bookchef/compilers/html.rb', line 7 def document @document end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/bookchef/compilers/html.rb', line 7 def result @result end |
Instance Method Details
#run ⇒ Object
16 17 18 19 |
# File 'lib/bookchef/compilers/html.rb', line 16 def run @result = BookChef.decode_special_chars(@document.serve) @result = BookChef.replace_https_with_http(@result) end |
#save_to(fn) ⇒ Object
21 22 23 24 25 |
# File 'lib/bookchef/compilers/html.rb', line 21 def save_to(fn) f = File.open(fn, "w") f.write @result f.close end |