Class: Metanorma::Compile::OutputFilename

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/compile/output_filename.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(noext_filename, output_dir = nil, processor = nil) ⇒ OutputFilename

Returns the instance of OutputFilename.

Parameters:

  • noext_filename (String)

    the path (absolute/relative) of the source file, without extension (e.g., “/a/b/c/test”)

  • output_dir (String, nil) (defaults to: nil)

    the output directory

  • processor (Metanorma::Processor, nil) (defaults to: nil)

    the processor



27
28
29
30
31
# File 'lib/metanorma/compile/output_filename.rb', line 27

def initialize(noext_filename, output_dir = nil, processor = nil)
  @noext_filename = noext_filename
  @output_dir = output_dir
  @processor = processor
end

Class Method Details

.from_filename(source_filename, output_dir = nil, processor = nil) ⇒ OutputFilename

Returns an instance of OutputFilename from the source filename

Parameters:

  • source_filename (String)

    the source filename

  • output_dir (String, nil) (defaults to: nil)

    the output directory

  • processor (Metanorma::Processor, nil) (defaults to: nil)

    the processor

Returns:



11
12
13
# File 'lib/metanorma/compile/output_filename.rb', line 11

def self.from_filename(source_filename, output_dir = nil, processor = nil)
  new(strip_ext(source_filename), output_dir, processor)
end

Instance Method Details

#for_format(format) ⇒ String?

Returns the full file path name with the given format extension

Parameters:

  • format (Symbol)

    the format

Returns:

  • (String, nil)

    the full file path name with the format extension



48
49
50
51
# File 'lib/metanorma/compile/output_filename.rb', line 48

def for_format(format)
  ext = @processor&.output_formats&.[](format)
  ext ? with_extension(ext) : nil
end

#presentation_xmlString

Returns the full file path name with the presentation XML extension

Returns:

  • (String)

    the full file path name with the presentation XML extension



41
42
43
# File 'lib/metanorma/compile/output_filename.rb', line 41

def presentation_xml
  with_extension("presentation.xml")
end

#semantic_xmlString

Returns the full file path name with the semantic XML extension

Returns:

  • (String)

    the full file path name with the semantic XML extension



35
36
37
# File 'lib/metanorma/compile/output_filename.rb', line 35

def semantic_xml
  with_extension("xml")
end

#with_extension(ext) ⇒ String

Returns the full file path name with the given extension

Parameters:

  • ext (String)

    the extension

Returns:

  • (String)

    the full file path name with the extension



56
57
58
59
# File 'lib/metanorma/compile/output_filename.rb', line 56

def with_extension(ext)
  file = change_output_dir
  "#{file}.#{ext}"
end