Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rescodegen/key_generator/code_safe_key_generator.rb

Instance Method Summary collapse

Instance Method Details

#protect_from_numbersObject



41
42
43
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 41

def protect_from_numbers
    sub(/(^[0-9])/, "_\\1")
end

#remove_duplicate_underscoresObject



33
34
35
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 33

def remove_duplicate_underscores
    gsub(/_+/, "_")
end

#replace_string_format_specifiersObject



21
22
23
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 21

def replace_string_format_specifiers
    gsub(/%\.[0-9]f|%[a-zA-Z@]+/, "_")
end

#replace_unsupported_charactersObject



25
26
27
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 25

def replace_unsupported_characters
    gsub(/[^a-zA-Z0-9]/, "_")
end

#replace_whitespaceObject



29
30
31
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 29

def replace_whitespace
    gsub(/\s+/, "_")
end

#trim_underscoresObject



37
38
39
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 37

def trim_underscores
    gsub(/^_|_$/, "")
end