Module: StringHelper
- Included in:
- GitVcsActions::Git
- Defined in:
- lib/core/helpers/string_helper.rb
Overview
Helper functions for strings
Instance Method Summary collapse
Instance Method Details
#camelize(str, upcase_first = true) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/core/helpers/string_helper.rb', line 3 def camelize(str, upcase_first = true) if upcase_first str = str.gsub(/^[a-z\d]*/) { $&.capitalize } else str = str.gsub(/^_/, "").gsub!(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase } end str.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{Regexp.last_match[2].capitalize}" }.gsub("/", "::") end |
#msg(default, message, delimiter = " - ") ⇒ Object
12 13 14 |
# File 'lib/core/helpers/string_helper.rb', line 12 def msg(default, , delimiter = " - ") .nil? ? default : "#{message}#{delimiter}#{default}" end |