Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/git_workflow/core_ext.rb
Instance Method Summary collapse
- #align(padding = '') ⇒ Object
- #blank? ⇒ Boolean
- #camelize ⇒ Object
- #constantize ⇒ Object
- #underscore ⇒ Object
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
21 22 23 |
# File 'lib/git_workflow/core_ext.rb', line 21 def blank? self =~ /^\s*$/ end |
#camelize ⇒ Object
29 30 31 |
# File 'lib/git_workflow/core_ext.rb', line 29 def camelize self.split('/').map { |v| v.gsub(/(?:^|_)(.)/) { $1.upcase } }.join('::') end |
#constantize ⇒ Object
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 |
#underscore ⇒ Object
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 |