Module: Arachni::Support::Mixins::Terminal

Extended by:
Terminal
Included in:
Terminal
Defined in:
lib/arachni/support/mixins/terminal.rb

Overview

Terminal manipulation methods.

Instance Method Summary collapse

Instance Method Details

#clear_screenObject

Clear the bottom of the screen



39
40
41
# File 'lib/arachni/support/mixins/terminal.rb', line 39

def clear_screen
    print "\e[2J"
end

#empty_screenObject



43
44
45
46
47
48
# File 'lib/arachni/support/mixins/terminal.rb', line 43

def empty_screen
    move_to_home
    rows, cols = $stdin.winsize
    (rows - 1).times{ puts ' ' * cols }
    move_to_home
end

#flushObject

Flushes the STDOUT buffer



56
57
58
# File 'lib/arachni/support/mixins/terminal.rb', line 56

def flush
    $stdout.flush
end

#move_to_homeObject

Moves cursor top left to its home



51
52
53
# File 'lib/arachni/support/mixins/terminal.rb', line 51

def move_to_home
    print "\e[H"
end

#reprint(str = '') ⇒ Object

Clears the line before printing.

Parameters:

  • str (String) (defaults to: '')

    String to output.



30
31
32
# File 'lib/arachni/support/mixins/terminal.rb', line 30

def reprint( str = '' )
    print restr( str )
end

#reputs(str = '') ⇒ Object

Clears the line before printing using `puts`.

Parameters:

  • str (String) (defaults to: '')

    String to output



22
23
24
# File 'lib/arachni/support/mixins/terminal.rb', line 22

def reputs( str = '' )
    reprint str + "\n"
end

#restr(str = '') ⇒ Object



34
35
36
# File 'lib/arachni/support/mixins/terminal.rb', line 34

def restr( str = '' )
    "\e[0K" + str
end