Sha256: fe37d61a0cd582b35bb0f1933fe855864b53aca6e149542221222201eebcf11c
Contents?: true
Size: 945 Bytes
Versions: 4
Compression:
Stored size: 945 Bytes
Contents
# frozen_string_literal: true module Lita # Handy utilities used by other Lita classes. # @api private module Util class << self # Returns a hash with any symbol keys converted to strings. # @param hash [Hash] The hash to convert. # @return [Hash] The converted hash. def stringify_keys(hash) result = {} hash.each_key { |key| result[key.to_s] = hash[key] } result end # Transforms a camel-cased string into a snaked-cased string. Taken from +ActiveSupport.+ # @param camel_cased_word [String] The word to transform. # @return [String] The transformed word. def underscore(camel_cased_word) word = camel_cased_word.to_s.dup word.gsub!("::", "/") word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr!("-", "_") word.downcase! word end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rita-5.0.0.alpha.4 | lib/lita/util.rb |
rita-5.0.0.alpha.3 | lib/lita/util.rb |
rita-5.0.0.alpha.2 | lib/lita/util.rb |
rita-5.0.0.alpha.1 | lib/lita/util.rb |