class Rubies::RandomArray
Public Instance Methods
generate()
click to toggle source
# File lib/rubies/random_array.rb, line 19 def generate depth = rand(0..3) nesting_array.flatten(depth) end
mini_array()
click to toggle source
# File lib/rubies/random_array.rb, line 4 def mini_array (-1_000..1_000).sort_by { rand }.sample 3 end
nesting_array()
click to toggle source
# File lib/rubies/random_array.rb, line 8 def nesting_array result = [] rand(1..3).times do result << mini_array end result.each do |array| array << self.mini_array end result end