class Rex::Ui::Text::Output::Stdio
This class implements output against standard out.
Attributes
io[W]
@!attribute io
The raw `IO` backing this Text output. Defaults to `$stdout` @return [#flush, #puts, #write]
Public Class Methods
new(options={})
click to toggle source
@param options [Hash{Symbol => IO}] @option options [IO]
Calls superclass method
Rex::Ui::Text::Output::new
# File lib/rex/ui/text/output/stdio.rb, line 34 def initialize(options={}) options.assert_valid_keys(:io) super() self.io = options[:io] end
Public Instance Methods
flush()
click to toggle source
Methods
# File lib/rex/ui/text/output/stdio.rb, line 46 def flush io.flush end
io()
click to toggle source
IO
to write to.
@return [IO] Default to `$stdout`
# File lib/rex/ui/text/output/stdio.rb, line 53 def io @io ||= $stdout end
print_raw(msg = '')
click to toggle source
Prints the supplied message to standard output.
# File lib/rex/ui/text/output/stdio.rb, line 60 def print_raw(msg = '') if (Rex::Compat.is_windows and supports_color?) WindowsConsoleColorSupport.new(io).write(msg) else io.print(msg) end io.flush msg end
Also aliased as: write
supports_color?()
click to toggle source
# File lib/rex/ui/text/output/stdio.rb, line 73 def supports_color? case config[:color] when true return true when false return false else # auto if (Rex::Compat.is_windows) return true end term = Rex::Compat.getenv('TERM') return (term and term.match(/(?:vt10[03]|xterm(?:-color)?|linux|screen|rxvt)/i) != nil) end end