class Rescodegen::CodeFormatter

Public Instance Methods

format_string(string) click to toggle source
# File lib/rescodegen/code_formatter/code_formatter.rb, line 5
def format_string(string)
        string.sub(/^[A-Z]+/) { |s| downcase_string_unless_acronym(s) }
        .gsub(/_[A-Z]+/) { |s| downcase_string_unless_acronym(s) }
end

Private Instance Methods

downcase_string_unless_acronym(string) click to toggle source
# File lib/rescodegen/code_formatter/code_formatter.rb, line 11
def downcase_string_unless_acronym(string)
    string.downcase! unless string.tr("_", "").size > 1
    string
end