class Mangadex::Utils

Public Class Methods

camelize(string, uppercase_first_letter = false) click to toggle source
# File lib/mangadex/utils.rb, line 6
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
underscore(string) click to toggle source
# File lib/mangadex/utils.rb, line 12
def underscore(string)
  string.gsub(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) do
    ($1 || $2) << "_"
  end.tr('-', '_').downcase
end