Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/hearken/monkey_violence.rb

Instance Method Summary collapse

Instance Method Details

#escape(char) ⇒ Object



8
9
10
# File 'lib/hearken/monkey_violence.rb', line 8

def escape(char)
  gsub(char) { "\\#{char}" }
end

#escape_all(chars) ⇒ Object



12
13
14
# File 'lib/hearken/monkey_violence.rb', line 12

def escape_all(chars)
  chars.inject(self) { |s, t| s.escape t }
end

#escape_for_shObject



16
17
18
# File 'lib/hearken/monkey_violence.rb', line 16

def escape_for_sh
  escape_all " `';&!()$".scan(/./)
end

#escape_for_sh_quotedObject



20
21
22
# File 'lib/hearken/monkey_violence.rb', line 20

def escape_for_sh_quoted
  escape "`"
end

#from_homeObject



4
5
6
# File 'lib/hearken/monkey_violence.rb', line 4

def from_home
  "#{File.expand_path("~")}/#{self}"
end