Module: Aether::String
- Defined in:
- lib/aetherg/string.rb
Instance Method Summary collapse
Instance Method Details
#camelcase ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/aetherg/string.rb', line 3 def camelcase return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/) altered_self = self.downcase.capitalize altered_self.scan(/[_-][a-zA-Z]/).each do |match| altered_self.gsub!(match, match[1].upcase) end altered_self end |
#camelcase! ⇒ Object
13 14 15 |
# File 'lib/aetherg/string.rb', line 13 def camelcase! self.replace camel_case end |
#filename ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aetherg/string.rb', line 17 def filename return self.gsub(/-/, "_") if !match(/[A-Z]/) altered_self = self.strip altered_self.scan(/[A-Z]/).each do |match| altered_self.gsub!(match, "_#{match.downcase}") end altered_self.sub(/^_/, "").gsub(/_{2,}+/, "_").downcase end |
#filename! ⇒ Object
28 29 30 |
# File 'lib/aetherg/string.rb', line 28 def filename! self.replace file_name end |