Class: Random

Inherits:
Object show all
Includes:
Nydp::Builtin::Base
Defined in:
lib/nydp/builtin/rng.rb

Instance Method Summary collapse

Methods included from Nydp::Builtin::Base

#call, #handle_error, ignore_errors, #inspect, #name, #nydp_type, #to_s

Methods included from Nydp::Helper

#cons, #list, #literal?, #pair?, #sig, #sym, #sym?

Methods included from Nydp::Converter

#n2r, #r2n, #rubify

Instance Method Details

#builtin_call(a0 = nil, a1 = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/nydp/builtin/rng.rb', line 16

def builtin_call a0=nil, a1=nil
  if a0 == nil
    self.rand
  elsif a1 == nil
    self.rand(a0)
  else
    (a0 + self.rand(a1 - a0))
  end
end