Class: Wordlist::Modifiers::Tr
- Defined in:
- lib/wordlist/modifiers/tr.rb
Overview
Lazily calls String#tr
on every word in the wordlist.
Instance Attribute Summary collapse
-
#chars ⇒ String
readonly
The characters or character range to translate.
-
#replace ⇒ String
readonly
The characters or character range to translate to.
Attributes inherited from Modifier
Instance Method Summary collapse
-
#each {|word| ... } ⇒ Enumerator
Enumerates over every
tr
ed word in the wordlist. -
#initialize(wordlist, chars, replace) ⇒ Tr
constructor
Initializes the
String#tr
modifier.
Constructor Details
#initialize(wordlist, chars, replace) ⇒ Tr
Initializes the String#tr
modifier.
32 33 34 35 36 37 |
# File 'lib/wordlist/modifiers/tr.rb', line 32 def initialize(wordlist,chars,replace) super(wordlist) @chars = chars @replace = replace end |
Instance Attribute Details
#chars ⇒ String (readonly)
The characters or character range to translate.
16 17 18 |
# File 'lib/wordlist/modifiers/tr.rb', line 16 def chars @chars end |
#replace ⇒ String (readonly)
The characters or character range to translate to.
21 22 23 |
# File 'lib/wordlist/modifiers/tr.rb', line 21 def replace @replace end |
Instance Method Details
#each {|word| ... } ⇒ Enumerator
Enumerates over every tr
ed word in the wordlist.
62 63 64 65 66 67 68 |
# File 'lib/wordlist/modifiers/tr.rb', line 62 def each return enum_for(__method__) unless block_given? @wordlist.each do |word| yield word.tr(@chars,@replace) end end |