Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/couchup/extensions/string.rb
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #camelize ⇒ Object
- #constantize ⇒ Object
-
#underscore ⇒ Object
cargo culted from rails inflector.
Instance Method Details
#blank? ⇒ Boolean
2 3 4 |
# File 'lib/couchup/extensions/string.rb', line 2 def blank? nil || strip.empty? end |
#camelize ⇒ Object
10 11 12 |
# File 'lib/couchup/extensions/string.rb', line 10 def camelize gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
#constantize ⇒ Object
6 7 8 |
# File 'lib/couchup/extensions/string.rb', line 6 def constantize Object.const_get(self) end |
#underscore ⇒ Object
cargo culted from rails inflector.
14 15 16 17 18 19 20 21 22 |
# File 'lib/couchup/extensions/string.rb', line 14 def underscore word = dup word.gsub!(/::/, '/') word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') word.tr!("-", "_") word.downcase! word end |