class String
Public Instance Methods
colorize(color_code)
click to toggle source
colorization
# File lib/mediainfo/string.rb 17 def colorize(color_code) 18 "\e[#{color_code}m#{self}\e[0m" 19 end
green()
click to toggle source
# File lib/mediainfo/string.rb 25 def green 26 colorize(32) 27 end
red()
click to toggle source
# File lib/mediainfo/string.rb 21 def red 22 colorize(31) 23 end
shell_escape_double_quotes()
click to toggle source
returns the string enclosed in double quotes. all characters in the string that could be harmful will be escaped.
e.g. 'test'.shell_escape_double_quotes # => “test” '$\'“`'.shell_escape_double_quotes # => ”$\'"`“
This should work in al POSIX compatible shells.
see: www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02_03
# File lib/mediainfo/string.rb 12 def shell_escape_double_quotes 13 ''+gsub(/\\|"|\$|`/, '\\\\\0')+'' 14 end
yellow()
click to toggle source
# File lib/mediainfo/string.rb 29 def yellow 30 colorize(33) 31 end