Class: String
Instance Method Summary collapse
Instance Method Details
#basename(options = {}) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/bake/string_utils.rb', line 2 def basename( = {}) if [:ext] return File.basename(self, extname) + [:ext] elsif [:noext] return File.basename(self, extname) end return File.basename(self) end |
#dirname ⇒ Object
11 12 13 |
# File 'lib/bake/string_utils.rb', line 11 def dirname return File.dirname(self) end |
#extname ⇒ Object
15 16 17 |
# File 'lib/bake/string_utils.rb', line 15 def extname return File.extname(self) end |
#underscore ⇒ Object
19 20 21 |
# File 'lib/bake/string_utils.rb', line 19 def underscore return gsub(/([a-z0-9])([A-Z])/) { |val| $1 + '_' + $2 }.downcase end |