Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string/pattern/add_to_ruby.rb
Instance Method Summary collapse
-
#generate(expected_errors: [], **synonyms) ⇒ Object
(also: #gen)
it will generate an string following the pattern specified.
-
#to_camel_case ⇒ Object
Convert to CamelCase a string.
-
#validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms) ⇒ Object
(also: #val)
it will validate an string following the pattern specified.
Instance Method Details
#generate(expected_errors: [], **synonyms) ⇒ Object Also known as: gen
it will generate an string following the pattern specified
21 22 23 |
# File 'lib/string/pattern/add_to_ruby.rb', line 21 def generate(expected_errors: [], **synonyms) StringPattern.generate(self, expected_errors: expected_errors, **synonyms) end |
#to_camel_case ⇒ Object
Convert to CamelCase a string
37 38 39 40 41 42 |
# File 'lib/string/pattern/add_to_ruby.rb', line 37 def to_camel_case return self if self !~ /_/ && self !~ /\s/ && self =~ /[A-Z]+.*/ gsub(/\W/, '_') .split('_').map(&:capitalize).join end |
#validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms) ⇒ Object Also known as: val
it will validate an string following the pattern specified
28 29 30 |
# File 'lib/string/pattern/add_to_ruby.rb', line 28 def validate(string_to_validate, expected_errors: [], not_expected_errors: [], **synonyms) StringPattern.validate(text: string_to_validate, pattern: self, expected_errors: expected_errors, not_expected_errors: not_expected_errors, **synonyms) end |