Class: OpencBot::AsciiIncrementer
- Inherits:
-
BaseIncrementer
- Object
- BaseIncrementer
- OpencBot::AsciiIncrementer
- Defined in:
- lib/openc_bot/incrementers/common.rb
Instance Method Summary collapse
- #increment_yielder ⇒ Object
-
#initialize(name, opts = {}) ⇒ AsciiIncrementer
constructor
A new instance of AsciiIncrementer.
Methods inherited from BaseIncrementer
#db_name, #each, #log_progress, new, #position_file_name, #progress_percent, #read_current, #reset_current, #resumable, #resuming_enum, #write_current
Constructor Details
#initialize(name, opts = {}) ⇒ AsciiIncrementer
Returns a new instance of AsciiIncrementer.
24 25 26 27 |
# File 'lib/openc_bot/incrementers/common.rb', line 24 def initialize(name, opts={}) @size = opts[:size] || 3 super(name, opts) end |
Instance Method Details
#increment_yielder ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/openc_bot/incrementers/common.rb', line 29 def increment_yielder alnum = (0...36).map{|i|i.to_s 36} # 0...z all_perms = alnum.repeated_permutation(@size) case @size when 1 @expected_count = 36 when 2 @expected_count = 1296 when 3 @expected_count = 46656 when 4 @expected_count = 1679616 end all_perms.each do |perm| yield perm.join end end |