Sha256: 5a563a0e2bf16e968022e286491b74f0a8e90bdc764f52e276a76a2951117874

Contents?: true

Size: 488 Bytes

Versions: 2

Compression:

Stored size: 488 Bytes

Contents

module FantasyFaker
  module ArrayUtils
    def self.const_array(argument)
      array = argument.is_a?(Array) ? argument : argument.to_a
      array.extend ArrayUtils
      freeze_all(array)
    end

    def self.rand(array)
      array.shuffle.sample
    end

    def self.freeze_all(array)
      array.each { |e| e.freeze }
      array.freeze
      array
    end

    def rand
      ArrayUtils.rand(self)
    end

    def freeze_all
      ArrayUtils.freeze_all(self)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fantasy_faker-0.0.3 lib/fantasy_faker/utils/array_utils.rb
fantasy_faker-0.0.2 lib/fantasy_faker/utils/array_utils.rb