module FFaker::ArrayUtils

Public Class Methods

const_array(argument) click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 9
def self.const_array(argument)
  array = argument.is_a?(Array) ? argument : argument.to_a
  array.extend ArrayUtils
  freeze_all(array)
end
freeze_all(array) click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 25
def self.freeze_all(array)
  array.each(&:freeze)
  array.freeze
  array
end
rand(array) click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 20
def self.rand(array)
  warn '[ArrayUtils.rand] is deprecated. Please use the ModuleUtils#fetch_sample method'
  fetch_sample(array)
end
random_pick(array, num) click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 15
def self.random_pick(array, num)
  warn '[ArrayUtils.random_pick] is deprecated. Please use the ModuleUtils#fetch_sample method'
  fetch_sample(array, count: num)
end
shuffle(array) click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 31
def self.shuffle(array)
  array.sort_by { FFaker::Random.rand }
end

Public Instance Methods

freeze_all() click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 45
def freeze_all
  ArrayUtils.freeze_all(self)
end
rand() click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 40
def rand
  warn '[ArrayUtils#rand] is deprecated. Please use the ModuleUtils#fetch_sample method'
  ArrayUtils.rand(self)
end
random_pick(num) click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 35
def random_pick(num)
  warn '[ArrayUtils#random_pick] is deprecated. Please use the ModuleUtils#fetch_sample method'
  ArrayUtils.random_pick(self, num)
end
shuffle() click to toggle source
# File lib/ffaker/utils/array_utils.rb, line 49
def shuffle
  ArrayUtils.shuffle(self)
end