Class: Ronin::Exploits::Loot::File Private
- Inherits:
-
Object
- Object
- Ronin::Exploits::Loot::File
- Defined in:
- lib/ronin/exploits/loot/file.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a loot file.
Instance Attribute Summary collapse
-
#contents ⇒ String, ...
readonly
private
The contents of the loot file.
-
#format ⇒ :json, ...
readonly
private
The desired output format for the loot file.
-
#path ⇒ String
readonly
private
The file name or relative path of the loot file.
Instance Method Summary collapse
-
#initialize(path, contents, format: nil) ⇒ File
constructor
private
Initializes the loot file.
-
#save(output_dir) ⇒ Object
private
Saves the loot file to the output directory.
-
#to_s ⇒ String
private
Converts the loot file into a String.
Constructor Details
#initialize(path, contents, format: nil) ⇒ File
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the loot file.
66 67 68 69 70 |
# File 'lib/ronin/exploits/loot/file.rb', line 66 def initialize(path,contents, format: nil) @path = path @contents = contents @format = format end |
Instance Attribute Details
#contents ⇒ String, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The contents of the loot file.
47 48 49 |
# File 'lib/ronin/exploits/loot/file.rb', line 47 def contents @contents end |
#format ⇒ :json, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The desired output format for the loot file.
52 53 54 |
# File 'lib/ronin/exploits/loot/file.rb', line 52 def format @format end |
#path ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The file name or relative path of the loot file.
42 43 44 |
# File 'lib/ronin/exploits/loot/file.rb', line 42 def path @path end |
Instance Method Details
#save(output_dir) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Saves the loot file to the output directory.
104 105 106 107 108 109 |
# File 'lib/ronin/exploits/loot/file.rb', line 104 def save(output_dir) absolute_path = ::File.join(output_dir,@path) FileUtils.mkdir_p(::File.dirname(absolute_path)) ::File.binwrite(absolute_path,self.to_s) end |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts the loot file into a String.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ronin/exploits/loot/file.rb', line 81 def to_s case @format when :json then JSON.pretty_generate(@contents) when :yaml then YAML.dump(@contents) when :csv CSV.generate do |csv| @contents.each do |row| csv << row end end when nil @contents.to_s else raise(NotImplementedError,"unsupported loot format: #{@format.inspect}") end end |