Class: Tools
- Inherits:
-
Object
- Object
- Tools
- Defined in:
- lib/tools.rb
Class Method Summary collapse
- .CommandNotFourd(cmd) ⇒ Object
- .figlet(text, font) ⇒ Object
- .parse_args(str) ⇒ Object
- .print(text) ⇒ Object
- .print_error(text) ⇒ Object
- .print_filget(figlet) ⇒ Object
- .print_help(text) ⇒ Object
- .print_msg(text) ⇒ Object
- .print_success(text) ⇒ Object
- .print_warning(text) ⇒ Object
Class Method Details
.CommandNotFourd(cmd) ⇒ Object
55 56 57 |
# File 'lib/tools.rb', line 55 def self.CommandNotFourd (cmd) Tools.print_error("'#{cmd}' command not found.\n") end |
.figlet(text, font) ⇒ Object
17 18 19 |
# File 'lib/tools.rb', line 17 def self.figlet (text , font) RubyFiglet::Figlet.new(text , font) end |
.parse_args(str) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/tools.rb', line 5 def self.parse_args (str) command_pattern = /^[a-zA-Z]+/ command = str.scan(command_pattern)[0] args_pattern = /-{1,2}([a-z-]+)[=|\s](\S+)/ parsed = str.scan(args_pattern) args = Hash.new parsed.each do |arg| args[arg[0].to_sym] = arg[1] end return command , args end |
.print(text) ⇒ Object
50 51 52 53 |
# File 'lib/tools.rb', line 50 def self.print (text) $stdout.write text.white $stdout.flush() end |
.print_error(text) ⇒ Object
40 41 42 43 |
# File 'lib/tools.rb', line 40 def self.print_error (text) $stdout.write "[!!!] ".red+text+"\n".white $stdout.flush() end |
.print_filget(figlet) ⇒ Object
21 22 23 |
# File 'lib/tools.rb', line 21 def self.print_filget (figlet) puts figlet.to_s.red end |
.print_help(text) ⇒ Object
25 26 27 28 |
# File 'lib/tools.rb', line 25 def self.print_help (text) $stdout.write "\n[@] ".blue+text.white $stdout.flush() end |
.print_msg(text) ⇒ Object
45 46 47 48 |
# File 'lib/tools.rb', line 45 def self.print_msg (text) $stdout.write "\n\n[~] ".green+text+"\n".white $stdout.flush() end |
.print_success(text) ⇒ Object
30 31 32 33 |
# File 'lib/tools.rb', line 30 def self.print_success (text) $stdout.write "[+] ".green+text+"\n".white $stdout.flush() end |
.print_warning(text) ⇒ Object
35 36 37 38 |
# File 'lib/tools.rb', line 35 def self.print_warning (text) $stdout.write "[!] ".yellow+text+"\n".white $stdout.flush() end |