Module: BotFramework::Util

Defined in:
lib/bot_framework/util.rb

Class Method Summary collapse

Class Method Details

.camel_case_lower(string) ⇒ Object



13
14
15
16
# File 'lib/bot_framework/util.rb', line 13

def camel_case_lower(string)
  string = string.to_s unless string.is_a? String
  string.split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end

.to_underscore(string) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/bot_framework/util.rb', line 4

def to_underscore(string)
  string = string.to_s unless string.is_a? String
  string.gsub(/::/, '/')
        .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
        .gsub(/([a-z\d])([A-Z])/, '\1_\2')
        .tr('-', '_')
        .downcase
end