class RealRand::FourmiLab
Public Class Methods
new()
click to toggle source
Calls superclass method
RealRand::OnlineGenerator::new
# File lib/random/online.rb, line 188 def initialize super("www.fourmilab.ch") end
Public Instance Methods
randbyte(nbytes = 128)
click to toggle source
# File lib/random/online.rb, line 192 def randbyte(nbytes = 128) if nbytes < 0 || nbytes > 2048 raise RangeError, "Invalid amount: #{nbytes}." end return [] if nbytes == 0 parameters = "nbytes=#{nbytes}&fmt=bin" response = get_response("/cgi-bin/uncgi/Hotbits", parameters) if response['content-type'] != 'application/octet-stream' raise "Unexpected content type: #{response['content-type']}." end result = [] response.body.each_byte { |b| result << b } result end