Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/mediainfo/string.rb

Instance Method Summary collapse

Instance Method Details

#shell_escapeObject



2
3
4
5
6
7
8
# File 'lib/mediainfo/string.rb', line 2

def shell_escape
  # The gsub is for ANSI-C style quoting.
  # 
  # The $'' is for bash, see http://www.faqs.org/docs/bashman/bashref_12.html,
  # but appears to be working for other shells: sh, zsh, ksh, dash
  "$'#{gsub(/\\|'/) { |c| "\\#{c}" }}'"
end

#underscoreObject

stolen from active_support/inflector TODO require “active_support/core_ext/string/inflections” when 3.0 is released



12
13
14
15
16
17
18
# File 'lib/mediainfo/string.rb', line 12

def underscore
  gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end