Sha256: 41e4097cb17763f93d31cb2646041a188a20cb6c68ef157c2a86925524b06a06
Contents?: true
Size: 781 Bytes
Versions: 2
Compression:
Stored size: 781 Bytes
Contents
# frozen_string_literal: true module ZohoHub class StringUtils class << self def demodulize(text) text.split('::').last end def pluralize(text) if ENV.key?('RAILS_ENV') ActiveSupport::Inflector.pluralize(text) else "#{text}s" end end def camelize(text) result = text.split(/[_\s]/) return result.first if result.size == 1 result.map(&:capitalize).join end def underscore(text) return text unless text =~ /[A-Z-]/ result = text.dup result.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') result.gsub!(/([a-z\d])([A-Z])/, '\1_\2') result.tr!('-', '_') result.downcase! result end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zoho_hub-0.4.0 | lib/zoho_hub/string_utils.rb |
zoho_hub-0.3.0 | lib/zoho_hub/string_utils.rb |