Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/git_workflow/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#align(padding = '') ⇒ Object



39
40
41
# File 'lib/git_workflow/core_ext.rb', line 39

def align(padding = '')
  self.gsub(/^\s+([^\s])/, "#{ padding }\\1")
end

#blank?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/git_workflow/core_ext.rb', line 21

def blank?
  self =~ /^\s*$/
end

#camelizeObject



29
30
31
# File 'lib/git_workflow/core_ext.rb', line 29

def camelize
  self.split('/').map { |v| v.gsub(/(?:^|_)(.)/) { $1.upcase } }.join('::')
end

#constantizeObject



33
34
35
36
37
# File 'lib/git_workflow/core_ext.rb', line 33

def constantize
  self.camelize.split('::').inject(Object) do |current,constant|
    current.const_get(constant) or current.const_missing(constant)
  end
end

#underscoreObject



25
26
27
# File 'lib/git_workflow/core_ext.rb', line 25

def underscore
  self.split('::').map { |v| v.gsub(/(.)([A-Z])/, '\1_\2') }.join('/').downcase
end