Class: Xmindoc::Core

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option) ⇒ Core

Returns a new instance of Core.



18
19
20
21
22
23
# File 'lib/xmindoc.rb', line 18

def initialize(option)
  @option = option
  @parser = Parser.new(option[:file_input])
  @exporter = Exporter.new(option)
  @result = ""
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



16
17
18
# File 'lib/xmindoc.rb', line 16

def result
  @result
end

Instance Method Details

#convertObject

Convert and process XML with Pandoc at once



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/xmindoc.rb', line 40

def convert()
  xml_to_html()
  html_to_pandoc()


  if @option[:file_output] == ""
    # Without -o option
    puts @result
  else
    # Using option: -o filename
    File.open(@option[:file_output],"w") do |f|
      f.write(@result)
    end
  end

  return @result
end

#html_to_pandocObject

Export with Pandoc: HTML -> Markdown, Org, …



33
34
35
36
37
# File 'lib/xmindoc.rb', line 33

def html_to_pandoc()
  @exporter.export()
  @result = @exporter.result
  return @result
end

#xml_to_htmlObject

Parse and transform: XML -> HTML



26
27
28
29
30
# File 'lib/xmindoc.rb', line 26

def xml_to_html()
  @parser.parse()
  @exporter.html = @parser.html_output
  return @exporter.html
end