module IbRubyProxy::Util::StringUtils
String utility methods
Public Instance Methods
to_camel_case(string)
click to toggle source
Converts passed string into camel case syntax
@see stackoverflow.com/a/11411200/469697
# File lib/ib_ruby_proxy/util/string_utils.rb, line 24 def to_camel_case(string) string.split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join end
to_underscore(string)
click to toggle source
Makes passed string underscored and lowercase
@param [String] string
Implementation copied from Rails @see api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore
# File lib/ib_ruby_proxy/util/string_utils.rb, line 13 def to_underscore(string) string.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end