Class: String

Inherits:
Object show all
Defined in:
lib/gitty/ext.rb

Instance Method Summary collapse

Instance Method Details

#classifyObject



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

#constantizeObject



19
20
21
# File 'lib/gitty/ext.rb', line 19

def constantize
  Object.module_eval("::" + self)
end

#underscoreObject



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