Class: IsoDoc::Ieee::IeeeXMLConvert

Inherits:
XslfoPdfConvert
  • Object
show all
Defined in:
lib/isodoc/ieee/ieee_xml_convert.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ IeeeXMLConvert

rubocop:disable Lint/MissingSuper



7
8
9
10
11
12
# File 'lib/isodoc/ieee/ieee_xml_convert.rb', line 7

def initialize(options) # rubocop:disable Lint/MissingSuper
  @libdir = File.dirname(__FILE__)
  @format = :ieee
  @suffix = "ieee.xml"
  @ieeedtd = options[:ieeedtd]
end

Instance Method Details

#convert(in_fname, file = nil, debug = false, out_fname = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/isodoc/ieee/ieee_xml_convert.rb', line 23

def convert(in_fname, file = nil, debug = false, out_fname = nil)
  file = File.read(in_fname, encoding: "utf-8") if file.nil?
  _docxml, filename, dir = convert_init(file, in_fname, debug)
  in_fname = inputfile(in_fname, filename)
  FileUtils.rm_rf dir
  opt = { input_format: MnConvert::InputFormat::MN,
          output_file: out_fname || "#{filename}.#{@suffix}",
          output_format: :ieee }
  @ieeedtd and opt.merge!(validation_against: @ieeedtd)
  MnConvert.convert(in_fname, opt)
end

#inputfile(in_fname, filename) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/isodoc/ieee/ieee_xml_convert.rb', line 14

def inputfile(in_fname, filename)
  /\.xml$/.match?(in_fname) or
    in_fname = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
      f.write file
      f.path
    end
  in_fname
end