Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/hearken/monkey_violence.rb
Instance Method Summary collapse
- #escape(char) ⇒ Object
- #escape_all(chars) ⇒ Object
- #escape_for_sh ⇒ Object
- #escape_for_sh_quoted ⇒ Object
- #from_home ⇒ Object
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_sh ⇒ Object
16 17 18 |
# File 'lib/hearken/monkey_violence.rb', line 16 def escape_for_sh escape_all " `';&!()$".scan(/./) end |
#escape_for_sh_quoted ⇒ Object
20 21 22 |
# File 'lib/hearken/monkey_violence.rb', line 20 def escape_for_sh_quoted escape "`" end |
#from_home ⇒ Object
4 5 6 |
# File 'lib/hearken/monkey_violence.rb', line 4 def from_home "#{File.expand_path("~")}/#{self}" end |