Module: Wordlist::ListMethods
- Included in:
- AbstractWordlist
- Defined in:
- lib/wordlist/list_methods.rb
Overview
List operator and modifier methods.
Operators collapse
-
#concat(other) ⇒ Operators::Concat
(also: #+)
Lazily enumerates over the first wordlist, then the second.
-
#intersect(other) ⇒ Operators::Intersect
(also: #&)
Lazily enumerates over every word that belongs to both wordlists.
-
#power(exponent) ⇒ Operators::Power
(also: #**)
Lazily enumerates over every combination of words in the wordlist.
-
#product(other) ⇒ Operators::Product
(also: #*)
Lazily enumerates over the combination of the words from two wordlists.
-
#subtract(other) ⇒ Operators::Subtract
(also: #-)
Lazily enumerates over every word in the first wordlist, that is not in the second wordlist.
-
#union(other) ⇒ Operators::Union
(also: #|)
Lazily enumerates over words from both wordlists, filtering out any duplicates.
-
#uniq ⇒ Operators::Unique
Lazily enumerates over only the unique words in the wordlist, filtering out duplicates.
Modifiers collapse
-
#capitalize ⇒ Capitalize
Lazily calls
String#capitalize
on each word in the wordlist. -
#downcase ⇒ Downcase
Lazily calls
String#downcase
on each word in the wordlist. -
#gsub(pattern, replace = nil) {|match| ... } ⇒ Gsub
Lazily calls
String#gsub
on each word in the wordlist. -
#mutate(pattern, replace = nil) {|match| ... } ⇒ Mutate
Lazily performs every combination of a string substitution on every word in the wordlist.
-
#mutate_case ⇒ EachCase
Lazily enumerates over every uppercase/lowercase variation of the word.
-
#sub(pattern, replace = nil) {|match| ... } ⇒ Sub
Lazily calls
String#sub
on each word in the wordlist. -
#tr(chars, replace) ⇒ Tr
Lazily calls
String#tr
on each word in the wordlist. -
#upcase ⇒ Upcase
Lazily calls
String#upcase
on each word in the wordlist.
Instance Method Details
#capitalize ⇒ Capitalize
Lazily calls String#capitalize
on each word in the wordlist.
335 336 337 |
# File 'lib/wordlist/list_methods.rb', line 335 def capitalize Modifiers::Capitalize.new(self) end |
#concat(other) ⇒ Operators::Concat Also known as: +
Lazily enumerates over the first wordlist, then the second.
39 40 41 |
# File 'lib/wordlist/list_methods.rb', line 39 def concat(other) Operators::Concat.new(self,other) end |
#downcase ⇒ Downcase
Lazily calls String#downcase
on each word in the wordlist.
377 378 379 |
# File 'lib/wordlist/list_methods.rb', line 377 def downcase Modifiers::Downcase.new(self) end |
#gsub(pattern, replace = nil) {|match| ... } ⇒ Gsub
Lazily calls String#gsub
on each word in the wordlist.
310 311 312 313 314 315 316 |
# File 'lib/wordlist/list_methods.rb', line 310 def gsub(pattern,replace=nil,&block) if replace Modifiers::Gsub.new(self,pattern,replace,&block) else Modifiers::Gsub.new(self,pattern,&block) end end |
#intersect(other) ⇒ Operators::Intersect Also known as: &
Lazily enumerates over every word that belongs to both wordlists.
151 152 153 |
# File 'lib/wordlist/list_methods.rb', line 151 def intersect(other) Operators::Intersect.new(self,other) end |
#mutate(pattern, replace = nil) {|match| ... } ⇒ Mutate
Lazily performs every combination of a string substitution on every word in the wordlist.
417 418 419 420 421 422 423 |
# File 'lib/wordlist/list_methods.rb', line 417 def mutate(pattern,replace=nil,&block) if replace Modifiers::Mutate.new(self,pattern,replace,&block) else Modifiers::Mutate.new(self,pattern,&block) end end |
#mutate_case ⇒ EachCase
Lazily enumerates over every uppercase/lowercase variation of the word.
# foo # Foo # fOo # foO # FOo # FoO # fOO # FOO # bar # Bar # bAr # baR # BAr # BaR # bAR # BAR
455 456 457 |
# File 'lib/wordlist/list_methods.rb', line 455 def mutate_case Modifiers::MutateCase.new(self) end |
#power(exponent) ⇒ Operators::Power Also known as: **
Lazily enumerates over every combination of words in the wordlist.
125 126 127 |
# File 'lib/wordlist/list_methods.rb', line 125 def power(exponent) Operators::Power.new(self,exponent) end |
#product(other) ⇒ Operators::Product Also known as: *
Lazily enumerates over the combination of the words from two wordlists.
94 95 96 |
# File 'lib/wordlist/list_methods.rb', line 94 def product(other) Operators::Product.new(self,other) end |
#sub(pattern, replace = nil) {|match| ... } ⇒ Sub
Lazily calls String#sub
on each word in the wordlist.
272 273 274 275 276 277 278 |
# File 'lib/wordlist/list_methods.rb', line 272 def sub(pattern,replace=nil,&block) if replace Modifiers::Sub.new(self,pattern,replace,&block) else Modifiers::Sub.new(self,pattern,&block) end end |
#subtract(other) ⇒ Operators::Subtract Also known as: -
Lazily enumerates over every word in the first wordlist, that is not in the second wordlist.
66 67 68 |
# File 'lib/wordlist/list_methods.rb', line 66 def subtract(other) Operators::Subtract.new(self,other) end |
#tr(chars, replace) ⇒ Tr
Lazily calls String#tr
on each word in the wordlist.
238 239 240 |
# File 'lib/wordlist/list_methods.rb', line 238 def tr(chars,replace) Modifiers::Tr.new(self,chars,replace) end |
#union(other) ⇒ Operators::Union Also known as: |
Lazily enumerates over words from both wordlists, filtering out any duplicates.
182 183 184 |
# File 'lib/wordlist/list_methods.rb', line 182 def union(other) Operators::Union.new(self,other) end |
#uniq ⇒ Operators::Unique
Lazily enumerates over only the unique words in the wordlist, filtering out duplicates.
207 208 209 |
# File 'lib/wordlist/list_methods.rb', line 207 def uniq Operators::Unique.new(self) end |