Class: String
Instance Method Summary collapse
Instance Method Details
#classify ⇒ Object
27 28 29 |
# File 'lib/gitty/ext.rb', line 27 def classify gsub(/^[a-z]/) { |l| l.upcase}.gsub(/_[a-z]/) { |l| l[1..1].upcase}.gsub(/\b[a-z]/) {|l| l.upcase}.gsub("/", "::") end |
#constantize ⇒ Object
19 20 21 |
# File 'lib/gitty/ext.rb', line 19 def constantize Object.module_eval("::" + self) end |
#underscore ⇒ Object
23 24 25 |
# File 'lib/gitty/ext.rb', line 23 def underscore gsub(/(^|\b)[A-Z]/) { |l| l.downcase}.gsub(/[A-Z]/) { |l| "_#{l.downcase}" }.gsub("::", "/") end |