Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/string_enhancer/core_ext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.analyze_batch(strings, batch_size: 100) ⇒ Object



73
74
75
# File 'lib/string_enhancer/core_ext.rb', line 73

def self.analyze_batch(strings, batch_size: 100)
  StringEnhancer.analyze_batch(strings, batch_size: batch_size)
end

.clear_cacheObject

Clear memoization cache



153
154
155
# File 'lib/string_enhancer/core_ext.rb', line 153

def self.clear_cache
  StringEnhancer.clear_cache
end

.decrypt(encrypted_str, key, algorithm: 'AES-256-CBC') ⇒ Object



90
91
92
# File 'lib/string_enhancer/core_ext.rb', line 90

def self.decrypt(encrypted_str, key, algorithm: 'AES-256-CBC')
  StringEnhancer.decrypt(encrypted_str, key, algorithm: algorithm)
end

.process_batch(strings, batch_size: 100, &block) ⇒ Object

Parallel processing



69
70
71
# File 'lib/string_enhancer/core_ext.rb', line 69

def self.process_batch(strings, batch_size: 100, &block)
  StringEnhancer.process_batch(strings, batch_size: batch_size, &block)
end

.similarity_matrix(strings, batch_size: 100) ⇒ Object



81
82
83
# File 'lib/string_enhancer/core_ext.rb', line 81

def self.similarity_matrix(strings, batch_size: 100)
  StringEnhancer.similarity_matrix(strings, batch_size: batch_size)
end

.transform_batch(strings, transformations, batch_size: 100) ⇒ Object



77
78
79
# File 'lib/string_enhancer/core_ext.rb', line 77

def self.transform_batch(strings, transformations, batch_size: 100)
  StringEnhancer.transform_batch(strings, transformations, batch_size: batch_size)
end

Instance Method Details

#alternating_caseObject

Returns a string with alternating case



23
24
25
# File 'lib/string_enhancer/core_ext.rb', line 23

def alternating_case
  StringEnhancer.alternating_case(self)
end

#analyzeObject

Advanced string analysis



33
34
35
# File 'lib/string_enhancer/core_ext.rb', line 33

def analyze
  StringEnhancer.analyze(self)
end

#best_match(candidates, threshold: 0.8) ⇒ Object



107
108
109
# File 'lib/string_enhancer/core_ext.rb', line 107

def best_match(candidates, threshold: 0.8)
  StringEnhancer.best_match(self, candidates, threshold: threshold)
end

#encrypt(key, algorithm: 'AES-256-CBC') ⇒ Object

Encryption



86
87
88
# File 'lib/string_enhancer/core_ext.rb', line 86

def encrypt(key, algorithm: 'AES-256-CBC')
  StringEnhancer.encrypt(self, key, algorithm: algorithm)
end

#extract_patternsObject



46
47
48
# File 'lib/string_enhancer/core_ext.rb', line 46

def extract_patterns
  StringEnhancer::PatternMatcher.extract_patterns(self)
end

#fuzzy_match(candidates, threshold: 0.8) ⇒ Object

Fuzzy matching



103
104
105
# File 'lib/string_enhancer/core_ext.rb', line 103

def fuzzy_match(candidates, threshold: 0.8)
  StringEnhancer.fuzzy_match(self, candidates, threshold: threshold)
end

#hash(algorithm: :sha256) ⇒ Object



94
95
96
# File 'lib/string_enhancer/core_ext.rb', line 94

def hash(algorithm: :sha256)
  StringEnhancer.hash(self, algorithm: algorithm)
end

#match_pattern(pattern) ⇒ Object

Pattern matching



38
39
40
# File 'lib/string_enhancer/core_ext.rb', line 38

def match_pattern(pattern)
  StringEnhancer.match_pattern(self, pattern)
end

#matches_pattern?(pattern_name) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/string_enhancer/core_ext.rb', line 42

def matches_pattern?(pattern_name)
  StringEnhancer::PatternMatcher.match_pattern(self, pattern_name)
end

#palindrome?Boolean

Returns true if the string is a palindrome

Returns:

  • (Boolean)


18
19
20
# File 'lib/string_enhancer/core_ext.rb', line 18

def palindrome?
  StringEnhancer.palindrome?(self)
end

#remove_consonantsObject

Returns a string with all consonants removed



13
14
15
# File 'lib/string_enhancer/core_ext.rb', line 13

def remove_consonants
  StringEnhancer.remove_consonants(self)
end

#remove_vowelsObject

Returns a string with all vowels removed



8
9
10
# File 'lib/string_enhancer/core_ext.rb', line 8

def remove_vowels
  StringEnhancer.remove_vowels(self)
end

#reverse_wordsObject

Returns a string with words in reverse order



28
29
30
# File 'lib/string_enhancer/core_ext.rb', line 28

def reverse_words
  StringEnhancer.reverse_words(self)
end

#sanitize(pattern_name) ⇒ Object



54
55
56
# File 'lib/string_enhancer/core_ext.rb', line 54

def sanitize(pattern_name)
  StringEnhancer::PatternMatcher.sanitize(self, pattern_name)
end

#secure_compare(other) ⇒ Object



98
99
100
# File 'lib/string_enhancer/core_ext.rb', line 98

def secure_compare(other)
  StringEnhancer.secure_compare(self, other)
end

#similarity(other) ⇒ Object

String similarity



64
65
66
# File 'lib/string_enhancer/core_ext.rb', line 64

def similarity(other)
  StringEnhancer.similarity(self, other)
end

#titleizeObject

Returns a string with the first letter of each word capitalized



3
4
5
# File 'lib/string_enhancer/core_ext.rb', line 3

def titleize
  StringEnhancer.titleize(self)
end

#transformObject

String transformation chain



59
60
61
# File 'lib/string_enhancer/core_ext.rb', line 59

def transform
  StringEnhancer::Transformer.transform(self)
end

#valid_credit_card?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/string_enhancer/core_ext.rb', line 136

def valid_credit_card?
  StringEnhancer.valid_credit_card?(self)
end

#valid_date?(format: '%Y-%m-%d') ⇒ Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/string_enhancer/core_ext.rb', line 124

def valid_date?(format: '%Y-%m-%d')
  StringEnhancer.valid_date?(self, format: format)
end

#valid_email?Boolean

Validation methods

Returns:

  • (Boolean)


112
113
114
# File 'lib/string_enhancer/core_ext.rb', line 112

def valid_email?
  StringEnhancer.valid_email?(self)
end

#valid_hex_color?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/string_enhancer/core_ext.rb', line 140

def valid_hex_color?
  StringEnhancer.valid_hex_color?(self)
end

#valid_ip?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/string_enhancer/core_ext.rb', line 132

def valid_ip?
  StringEnhancer.valid_ip?(self)
end

#valid_json?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/string_enhancer/core_ext.rb', line 144

def valid_json?
  StringEnhancer.valid_json?(self)
end

#valid_phone?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/string_enhancer/core_ext.rb', line 120

def valid_phone?
  StringEnhancer.valid_phone?(self)
end

#valid_time?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/string_enhancer/core_ext.rb', line 128

def valid_time?
  StringEnhancer.valid_time?(self)
end

#valid_url?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/string_enhancer/core_ext.rb', line 116

def valid_url?
  StringEnhancer.valid_url?(self)
end

#valid_xml?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/string_enhancer/core_ext.rb', line 148

def valid_xml?
  StringEnhancer.valid_xml?(self)
end

#validate_format(pattern_name) ⇒ Object



50
51
52
# File 'lib/string_enhancer/core_ext.rb', line 50

def validate_format(pattern_name)
  StringEnhancer::PatternMatcher.validate_format(self, pattern_name)
end