Sha256: 86a54649b0795205f0d525da4ee9a99cafefab5f68ac9a2a5599c8debf72a36a

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 Bytes

Contents

module CatIpsum
  class Random
    class << self
      def seed
        @seed ||= ::Random.new_seed
      end

      def seed=(value)
        @seed = value
        reset!
        value
      end

      def reset!
        @randomizer = randomize
        true
      end

      def randomizer
        @randomizer ||= randomize
      end

      def randomize
        ::Random.new(seed)
      end

      def sample(array, count: 3)
        array.shuffle(random: randomizer).take(count)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cat_ipsum-0.2.2 lib/cat_ipsum/random.rb