Class: Array

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

Overview

Copyright © 2013 Michael Dvorkin

Unbelievable is freely distributable under the terms of MIT license. See LICENSE file or www.opensource.org/licenses/mit-license.php

Instance Method Summary collapse

Instance Method Details

#pick(size) ⇒ Object



7
8
9
10
# File 'lib/unbelievable/core_ext/array.rb', line 7

def pick(size)
  word = self.select { |item| item.size == size }.sample
  word ||= "x" * size # Only if we miss the word in the dictionary.
end