Module: Ronin::Core::OutputFormats::ClassMethods

Defined in:
lib/ronin/core/output_formats.rb

Overview

Class methods which are added to another OutputFormats module when Ronin::Core::OutputFormats is included.

Instance Method Summary collapse

Instance Method Details

#file_extsHash{String => Class<OutputFormat>}

Output formats grouped by file extension.

Returns:



61
62
63
# File 'lib/ronin/core/output_formats.rb', line 61

def file_exts
  @file_exts ||= {}
end

#formatsHash{Symbol => Class<OutputFormat>}

Output formats grouped by name.

Returns:



52
53
54
# File 'lib/ronin/core/output_formats.rb', line 52

def formats
  @formats ||= {}
end

#infer_from(path) ⇒ Class<OutputFormat>, Class<TXT>

Infers the output format from the output file path.

Parameters:

  • path (String)

    The output file path to infer the output format from.

Returns:

  • (Class<OutputFormat>, Class<TXT>)

    The inferred output format for the given path, or TXT if the output format could not be inferred.



92
93
94
# File 'lib/ronin/core/output_formats.rb', line 92

def infer_from(path)
  file_exts.fetch(File.extname(path),TXT)
end

#register(name, ext, output_format) ⇒ Object

Registers a new output format.

Parameters:

  • name (Symbol)

    The output format name.

  • ext (String)

    The file extension associated with the output format.

  • output_format (Class)

    The output format class.



77
78
79
80
# File 'lib/ronin/core/output_formats.rb', line 77

def register(name,ext,output_format)
  formats[name]  = output_format
  file_exts[ext] = output_format
end