Class: Emfsvg::BsdRand

Inherits:
Object
  • Object
show all
Defined in:
lib/emfsvg/bsd_rand.rb

Overview

Replicates BSD rand() (macOS libc default) with default seed 1, which libemf2svg relies on for clip-path IDs via get_id() → rand().

The first call returns 16807, then 282475249, 1622650073, ... We pre-load 5000 values from a generated table to keep the runtime trivial. If more are needed, extend the table via scripts/dump_rand.c.

Constant Summary collapse

SEQUENCE_PATH =
File.expand_path("bsd_rand_sequence.txt", __dir__)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.valuesObject (readonly)

Returns the value of attribute values.



26
27
28
# File 'lib/emfsvg/bsd_rand.rb', line 26

def values
  @values
end

Class Method Details

.nextObject



16
17
18
19
20
# File 'lib/emfsvg/bsd_rand.rb', line 16

def next
  v = @values[@index]
  @index += 1
  v
end

.resetObject



22
23
24
# File 'lib/emfsvg/bsd_rand.rb', line 22

def reset
  @index = 0
end