File: random_compat.rb

package info (click to toggle)
ruby-cbor 0.5.9.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 424 kB
  • sloc: ansic: 3,437; ruby: 1,732; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 334 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

unless defined? Random
  class Random
    def initialize(seed=Time.now.to_i)
      Kernel.srand(seed)
      @seed = seed
    end

    attr_reader :seed

    def rand(arg)
      Kernel.rand(arg)
    end

    def bytes(n)
      array = []
      n.times do
        array << rand(256)
      end
      array.pack('C*')
    end
  end
end