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.



83
84
85
# File 'lib/ronin/core/output_formats.rb', line 83

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

#register(name, ext, output_format) ⇒ Object

Registers a new output format.



68
69
70
71
# File 'lib/ronin/core/output_formats.rb', line 68

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