Module: Ronin::UI::Output::Helpers
- Included in:
- Network::Mixins::Mixin, Support, Shell
- Defined in:
- lib/ronin/ui/output/helpers.rb
Overview
Helper methods for printing output.
Class Method Summary collapse
-
.format(arguments) ⇒ String
protected
private
Formats a message to be printed.
Instance Method Summary collapse
-
#print_debug(*message) ⇒ Boolean
Prints a
debug
message. -
#print_error(*message) ⇒ Boolean
Prints an
error
message. -
#print_exception(exception) ⇒ Boolean
Prints an exception.
-
#print_info(*message) ⇒ Boolean
Prints an
info
message. -
#print_warning(*message) ⇒ Boolean
Prints a
warning
message. -
#printf(format, *arguments) ⇒ nil
Prints formatted data.
-
#putc(data) ⇒ String, Integer
Prints a character.
-
#puts(*arguments) ⇒ Object
Prints one or more messages.
-
#write(data) ⇒ Integer?
Writes data unless output has been silenced.
Class Method Details
.format(arguments) ⇒ String (protected)
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.
Formats a message to be printed.
286 287 288 289 290 291 292 |
# File 'lib/ronin/ui/output/helpers.rb', line 286 def Helpers.format(arguments) unless arguments.length == 1 arguments.first % arguments[1..-1] else arguments.first end end |
Instance Method Details
#print_debug(*message) ⇒ Boolean
Prints a debug
message.
174 175 176 177 178 179 180 181 |
# File 'lib/ronin/ui/output/helpers.rb', line 174 def print_debug(*) if (Output.verbose? && !(Output.silent?)) Output.handler.print_debug(Helpers.format()) return true end return false end |
#print_error(*message) ⇒ Boolean
Prints an error
message.
230 231 232 233 234 235 236 237 |
# File 'lib/ronin/ui/output/helpers.rb', line 230 def print_error(*) unless Output.silent? Output.handler.print_error(Helpers.format()) return true end return false end |
#print_exception(exception) ⇒ Boolean
Prints an exception.
259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/ronin/ui/output/helpers.rb', line 259 def print_exception(exception) return false if Output.silent? print_error "#{exception.class}: #{exception.}" if Output.verbose? exception.backtrace[0,5].each do |line| print_error " #{line}" end end return true end |
#print_info(*message) ⇒ Boolean
Prints an info
message.
149 150 151 152 153 154 155 156 |
# File 'lib/ronin/ui/output/helpers.rb', line 149 def print_info(*) unless Output.silent? Output.handler.print_info(Helpers.format()) return true end return false end |
#print_warning(*message) ⇒ Boolean
Prints a warning
message.
202 203 204 205 206 207 208 209 |
# File 'lib/ronin/ui/output/helpers.rb', line 202 def print_warning(*) unless Output.silent? Output.handler.print_warning(Helpers.format()) return true end return false end |
#printf(format, *arguments) ⇒ nil
Prints formatted data.
125 126 127 128 |
# File 'lib/ronin/ui/output/helpers.rb', line 125 def printf(format,*arguments) write(format % arguments) return nil end |
#putc(data) ⇒ String, Integer
Prints a character.
64 65 66 67 68 69 |
# File 'lib/ronin/ui/output/helpers.rb', line 64 def putc(data) char = data.chr if data.kind_of?(Integer) write(data) return data end |
#puts(*arguments) ⇒ Object
Prints one or more messages.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ronin/ui/output/helpers.rb', line 84 def puts(*arguments) if arguments.empty? write($/) return nil end arguments.each do |argument| if argument.kind_of?(Array) argument.each { |element| puts(element) } else str = case argument when nil if RUBY_VERSION > '1.9' then '' else 'nil' end else argument.to_s end write("#{str}#{$/}") end end return nil end |