Class: Xmindoc::Parser
- Inherits:
-
Object
- Object
- Xmindoc::Parser
- Defined in:
- lib/xmindoc/parser.rb
Constant Summary collapse
- CONTENT_XML_FILE =
"content.xml"
- XSLT_FILE =
"#{SRC_DIR}/content.xsl"
Instance Attribute Summary collapse
-
#file_xmind ⇒ Object
Returns the value of attribute file_xmind.
-
#html_output ⇒ Object
readonly
Returns the value of attribute html_output.
-
#xml_content ⇒ Object
readonly
Returns the value of attribute xml_content.
Instance Method Summary collapse
-
#initialize(file_xmind) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Object
Parse a XMind XML and convert it to html.
Constructor Details
#initialize(file_xmind) ⇒ Parser
Returns a new instance of Parser.
22 23 24 25 26 27 28 29 |
# File 'lib/xmindoc/parser.rb', line 22 def initialize(file_xmind) Dir::chdir(".") @file_xmind = file_xmind @xslt = File.read(XSLT_FILE) @nokogiri_xslt = Nokogiri::XSLT(@xslt) @xml_content = '' @html_output = '' end |
Instance Attribute Details
#file_xmind ⇒ Object
Returns the value of attribute file_xmind.
17 18 19 |
# File 'lib/xmindoc/parser.rb', line 17 def file_xmind @file_xmind end |
#html_output ⇒ Object (readonly)
Returns the value of attribute html_output.
18 19 20 |
# File 'lib/xmindoc/parser.rb', line 18 def html_output @html_output end |
#xml_content ⇒ Object (readonly)
Returns the value of attribute xml_content.
18 19 20 |
# File 'lib/xmindoc/parser.rb', line 18 def xml_content @xml_content end |
Instance Method Details
#parse ⇒ Object
Parse a XMind XML and convert it to html
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/xmindoc/parser.rb', line 32 def parse() ## Read XMind file as a zip file Zip::Archive.open(@file_xmind) do |ar| ar.fopen(CONTENT_XML_FILE) do |f| @xml_content = f.read end end ## Parse XMind XML with Nokogiri and XSLT nokogiri_xml = Nokogiri::XML(@xml_content) @html_output = @nokogiri_xslt.apply_to(nokogiri_xml).to_s end |