Class: Ronin::Core::OutputFormats::OutputDir

Inherits:
OutputFormat show all
Defined in:
lib/ronin/core/output_formats/output_dir.rb

Overview

Base class that represents an output directory.

Since:

  • 0.2.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OutputFormat

#<<

Constructor Details

#initialize(path) ⇒ OutputDir

Initializes the output directory.

Parameters:

  • path (String)

    The path to the output directory.

Since:

  • 0.2.0



46
47
48
49
50
51
# File 'lib/ronin/core/output_formats/output_dir.rb', line 46

def initialize(path)
  super()

  @path = File.expand_path(path)
  FileUtils.mkdir_p(@path)
end

Instance Attribute Details

#pathString (readonly)

The path to the output directory.

Returns:

  • (String)

Since:

  • 0.2.0



38
39
40
# File 'lib/ronin/core/output_formats/output_dir.rb', line 38

def path
  @path
end

Class Method Details

.open(path) {|output_dir| ... } ⇒ Dir

Opens an output directory.

Parameters:

  • path (String)

    The path to the new output directory.

Yields:

  • (output_dir)

    If a block is given, it will be passed the initialized output directory. Once the block returns, the output format will automatically be closed.

Yield Parameters:

  • output_dir (Dir)

    The newly opened output directory.

Returns:

  • (Dir)

    If no block is given, the newly initialized output directory will be returned.

Since:

  • 0.2.0



71
72
73
74
75
76
77
78
79
80
# File 'lib/ronin/core/output_formats/output_dir.rb', line 71

def self.open(path)
  output_dir = new(path)

  if block_given?
    yield output_dir
    output_dir.close
  else
    return output_dir
  end
end

Instance Method Details

#closeObject

Note:

This method is mainly for compatibility with Ronin::Core::OutputFormats::OutputFile.

"Closes" the output directory.

Since:

  • 0.2.0



87
88
# File 'lib/ronin/core/output_formats/output_dir.rb', line 87

def close
end