Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #erb_eval(b) ⇒ Object
- #sans(str) ⇒ Object
- #underscore ⇒ Object
- #write(path) ⇒ Object
Instance Method Details
#blank? ⇒ Boolean
19 20 21 |
# File 'lib/core_ext/string.rb', line 19 def blank? gsub(/\t|\s/, '').empty? end |
#erb_eval(b) ⇒ Object
4 5 6 |
# File 'lib/core_ext/string.rb', line 4 def erb_eval(b) ERB.new(self).result(b) end |
#sans(str) ⇒ Object
15 16 17 |
# File 'lib/core_ext/string.rb', line 15 def sans(str) gsub(str, '') end |
#underscore ⇒ Object
23 24 25 |
# File 'lib/core_ext/string.rb', line 23 def underscore gsub(/\W+/, '_') end |
#write(path) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/core_ext/string.rb', line 8 def write(path) File.open(path, 'w+') do |file| file << self end puts "- #{path}" end |