Class: Ronin::CLI::StringProcessorCommand Private
- Inherits:
-
FileProcessorCommand
- Object
- Core::CLI::Command
- Command
- FileProcessorCommand
- Ronin::CLI::StringProcessorCommand
- Defined in:
- lib/ronin/cli/string_processor_command.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.
Similar to FileProcessorCommand, but also accept raw strings via the
--string STR
option and files via the --file FILE
option.
Direct Known Subclasses
Commands::Hmac, Commands::Md5, Commands::Rot, Commands::Sha1, Commands::Sha256, Commands::Sha512, Commands::Xor, StringMethodsCommand
Defined Under Namespace
Classes: FileValue, StringValue
Instance Attribute Summary collapse
-
#input_values ⇒ Array<StringValue, FileValue>
readonly
private
The input values to process.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ StringProcessorCommand
constructor
private
Initializes the string processor command.
-
#print_string(string) ⇒ Object
private
Prints a string value.
-
#process_input(input) ⇒ Object
private
Processes an input stream.
-
#process_string(string) ⇒ String
abstract
private
Processes the string.
-
#run(*files) ⇒ Object
private
Runs the command.
Methods inherited from FileProcessorCommand
Constructor Details
#initialize(**kwargs) ⇒ StringProcessorCommand
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 string processor command.
113 114 115 116 117 |
# File 'lib/ronin/cli/string_processor_command.rb', line 113 def initialize(**kwargs) super(**kwargs) @input_values = [] end |
Instance Attribute Details
#input_values ⇒ Array<StringValue, FileValue> (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 input values to process.
105 106 107 |
# File 'lib/ronin/cli/string_processor_command.rb', line 105 def input_values @input_values end |
Instance Method Details
#print_string(string) ⇒ 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.
Prints a string value.
164 165 166 |
# File 'lib/ronin/cli/string_processor_command.rb', line 164 def print_string(string) puts string end |
#process_input(input) ⇒ 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.
Processes an input stream.
148 149 150 151 152 153 154 155 156 |
# File 'lib/ronin/cli/string_processor_command.rb', line 148 def process_input(input) if [:multiline] input.each_line(chomp: ![:keep_newlines]) do |line| print_string(process_string(line)) end else print_string(process_string(input.read)) end end |
#process_string(string) ⇒ 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.
Processes the string.
179 180 181 |
# File 'lib/ronin/cli/string_processor_command.rb', line 179 def process_string(string) raise(NotImplementedError,"#{self.class}##{__method__} method was not implemented") end |
#run(*files) ⇒ 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.
Runs the command.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/ronin/cli/string_processor_command.rb', line 125 def run(*files) if (files.empty? && @input_values.empty?) process_input(stdin) else @input_values.each do |value| case value when StringValue print_string(process_string(value.string)) when FileValue process_file(value.file) end end files.each(&method(:process_file)) end end |