Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/mediainfo/string.rb
Instance Method Summary collapse
-
#colorize(color_code) ⇒ Object
colorization.
- #green ⇒ Object
- #red ⇒ Object
-
#shell_escape_double_quotes ⇒ Object
returns the string enclosed in double quotes.
- #yellow ⇒ Object
Instance Method Details
#colorize(color_code) ⇒ Object
colorization
17 18 19 |
# File 'lib/mediainfo/string.rb', line 17 def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end |
#green ⇒ Object
25 26 27 |
# File 'lib/mediainfo/string.rb', line 25 def green colorize(32) end |
#red ⇒ Object
21 22 23 |
# File 'lib/mediainfo/string.rb', line 21 def red colorize(31) end |
#shell_escape_double_quotes ⇒ Object
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
12 13 14 |
# File 'lib/mediainfo/string.rb', line 12 def shell_escape_double_quotes ''+gsub(/\\|"|\$|`/, '\\\\\0')+'' end |
#yellow ⇒ Object
29 30 31 |
# File 'lib/mediainfo/string.rb', line 29 def yellow colorize(33) end |