Class: Sass::Util::CrossPlatformRandom

Inherits:
Object
  • Object
show all
Defined in:
/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/cross_platform_random.rb

Overview

Ruby 1.8 doesn’t support an actual Random class with a settable seed.

Instance Method Summary (collapse)

Constructor Details

- (CrossPlatformRandom) initialize(seed = nil)

Returns a new instance of CrossPlatformRandom



5
6
7
8
9
10
11
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/cross_platform_random.rb', line 5

def initialize(seed = nil)
  if Sass::Util.ruby1_8?
    srand(seed) if seed
  else
    @random = seed ? ::Random.new(seed) : ::Random.new
  end
end

Instance Method Details

- rand(*args)



13
14
15
16
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/util/cross_platform_random.rb', line 13

def rand(*args)
  return @random.rand(*args) if @random
  Kernel.rand(*args)
end