Module: FFaker::ArrayUtils
- Extended by:
- RandomUtils
- Defined in:
- lib/ffaker/utils/array_utils.rb
Class Method Summary collapse
- .const_array(argument) ⇒ Object
- .freeze_all(array) ⇒ Object
- .rand(array) ⇒ Object
- .random_pick(array, num) ⇒ Object
- .shuffle(array) ⇒ Object
Instance Method Summary collapse
Methods included from RandomUtils
Class Method Details
.const_array(argument) ⇒ Object
9 10 11 12 13 |
# 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) ⇒ Object
25 26 27 28 29 |
# File 'lib/ffaker/utils/array_utils.rb', line 25 def self.freeze_all(array) array.each(&:freeze) array.freeze array end |
.rand(array) ⇒ Object
20 21 22 23 |
# 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) ⇒ Object
15 16 17 18 |
# 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 |
Instance Method Details
#freeze_all ⇒ Object
45 46 47 |
# File 'lib/ffaker/utils/array_utils.rb', line 45 def freeze_all ArrayUtils.freeze_all(self) end |
#rand ⇒ Object
40 41 42 43 |
# 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) ⇒ Object
35 36 37 38 |
# 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 ⇒ Object
49 50 51 |
# File 'lib/ffaker/utils/array_utils.rb', line 49 def shuffle ArrayUtils.shuffle(self) end |