Module: IbRubyProxy::Util::StringUtils
- Extended by:
- StringUtils
- Included in:
- Server::IbClientAdapter, Server::IbRubyClassSourceGenerator, Server::IbWrapperAdapter, Server::Reflection::IbClass, StringUtils
- Defined in:
- lib/ib_ruby_proxy/util/string_utils.rb
Overview
String utility methods
Instance Method Summary collapse
-
#to_camel_case(string) ⇒ Object
Converts passed string into camel case syntax.
-
#to_underscore(string) ⇒ Object
Makes passed string underscored and lowercase.
Instance Method Details
#to_camel_case(string) ⇒ Object
Converts passed string into camel case syntax
24 25 26 |
# 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) ⇒ Object
Makes passed string underscored and lowercase
Implementation copied from Rails
13 14 15 16 17 18 19 |
# 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 |