Sha256: 58e577286717b25cb466e0a7d1942982c1e3f176b0568d1d0c129faf9b3bd3e3
Contents?: true
Size: 579 Bytes
Versions: 2
Compression:
Stored size: 579 Bytes
Contents
# typed: false module Mangadex class Utils class << self def camelize(string, uppercase_first_letter = false) string.split('_').each_with_index.map do |x, i| i == 0 && !uppercase_first_letter ? x : x.capitalize end.join end def underscore(string) is_symbol = string.kind_of?(Symbol) data = string.to_s result = data.gsub(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do ($1 || $2) << "_" end.tr('-', '_').downcase is_symbol ? result.to_sym : result end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mangadex-5.10.0 | lib/mangadex/utils.rb |
mangadex-5.9.0 | lib/mangadex/utils.rb |