Class: StringPattern
- Inherits:
-
Object
- Object
- StringPattern
- Defined in:
- lib/string_pattern.rb
Overview
SP_ADD_TO_RUBY: (TrueFalse, default: true) You need to add this constant value before requiring the library if you want to modify the default. If true it will add 'generate' and 'validate' methods to the classes: Array, String and Symbol. Also it will add 'generate' method to Kernel aliases: 'gen' for 'generate' and 'val' for 'validate' Examples of use: "(,3:N,) ,3:N,-,2:N,-,2:N".split(",").generate #>(937) 980-65-05 %w3:N ) 1:_ 3:N - 2:N - 2:N.gen #>(045) 448-63-09 ["1:L", "5-10:LN", "-", "3:N"].gen #>zqWihV-746 gen("10:N") #>3433409877 "20-30:@".gen #>[email protected] "10:L/N/[/-./%d%]".validate("12ds6f--.s") #>[:value, :string_set_not_allowed] "20-40:@".validate(my_email) national_chars: (Array, default: english alphabet) Set of characters that will be used when using T pattern optimistic: (TrueFalse, default: true) If true it will check on the strings of the array positions if they have the pattern format and assume in that case that is a pattern. dont_repeat: (TrueFalse, default: false) If you want to generate for example 1000 strings and be sure all those strings are different you can set it to true default_infinite: (Integer, default: 10) In case using regular expressions the maximum when using * or + for repetitions word_separator: (String, default: '_') When generating words using symbol types 'w' or 'p' the character to separate the english or spanish words.
Defined Under Namespace
Classes: Pattern
Constant Summary collapse
- NUMBER_SET =
("0".."9").to_a
- SPECIAL_SET =
[" ", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "=", "{", "}", "[", "]", "'", ";", ":", "?", ">", "<", "`", "|", "/", '"']
- ALPHA_SET_LOWER =
("a".."z").to_a
- ALPHA_SET_CAPITAL =
("A".."Z").to_a
Class Attribute Summary collapse
-
.cache ⇒ Object
Returns the value of attribute cache.
-
.cache_values ⇒ Object
Returns the value of attribute cache_values.
-
.default_infinite ⇒ Object
Returns the value of attribute default_infinite.
-
.dont_repeat ⇒ Object
Returns the value of attribute dont_repeat.
-
.national_chars ⇒ Object
Returns the value of attribute national_chars.
-
.optimistic ⇒ Object
Returns the value of attribute optimistic.
-
.word_separator ⇒ Object
Returns the value of attribute word_separator.
Class Attribute Details
.cache ⇒ Object
Returns the value of attribute cache.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def cache @cache end |
.cache_values ⇒ Object
Returns the value of attribute cache_values.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def cache_values @cache_values end |
.default_infinite ⇒ Object
Returns the value of attribute default_infinite.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def default_infinite @default_infinite end |
.dont_repeat ⇒ Object
Returns the value of attribute dont_repeat.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def dont_repeat @dont_repeat end |
.national_chars ⇒ Object
Returns the value of attribute national_chars.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def national_chars @national_chars end |
.optimistic ⇒ Object
Returns the value of attribute optimistic.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def optimistic @optimistic end |
.word_separator ⇒ Object
Returns the value of attribute word_separator.
30 31 32 |
# File 'lib/string_pattern.rb', line 30 def word_separator @word_separator end |