Class: Array
Instance Method Summary collapse
- #list_join(sep = ', ') ⇒ Object
- #rand(count = 1) ⇒ Object
- #rand!(count = 1) ⇒ Object
- #shuffle ⇒ Object
- #shuffle! ⇒ Object
Instance Method Details
#list_join(sep = ', ') ⇒ Object
21 22 23 |
# File 'lib/iron/extensions/array.rb', line 21 def list_join(sep = ', ') self.select{|e| !e.blank?}.join(sep) end |
#rand(count = 1) ⇒ Object
13 14 15 |
# File 'lib/iron/extensions/array.rb', line 13 def rand(count = 1) shuffle[0...count] end |
#rand!(count = 1) ⇒ Object
17 18 19 |
# File 'lib/iron/extensions/array.rb', line 17 def rand!(count = 1) self.replace rand(count) end |
#shuffle ⇒ Object
4 5 6 |
# File 'lib/iron/extensions/array.rb', line 4 def shuffle sort_by { Kernel.rand } end |
#shuffle! ⇒ Object
8 9 10 |
# File 'lib/iron/extensions/array.rb', line 8 def shuffle! self.replace shuffle end |