Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rescodegen/key_generator/code_safe_key_generator.rb
Instance Method Summary collapse
- #protect_from_numbers ⇒ Object
- #remove_duplicate_underscores ⇒ Object
- #replace_string_format_specifiers ⇒ Object
- #replace_unsupported_characters ⇒ Object
- #replace_whitespace ⇒ Object
- #trim_underscores ⇒ Object
Instance Method Details
#protect_from_numbers ⇒ Object
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_underscores ⇒ Object
33 34 35 |
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 33 def remove_duplicate_underscores gsub(/_+/, "_") end |
#replace_string_format_specifiers ⇒ Object
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_characters ⇒ Object
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_whitespace ⇒ Object
29 30 31 |
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 29 def replace_whitespace gsub(/\s+/, "_") end |
#trim_underscores ⇒ Object
37 38 39 |
# File 'lib/rescodegen/key_generator/code_safe_key_generator.rb', line 37 def trim_underscores gsub(/^_|_$/, "") end |