Sha256: b9f1c5fbfae84eb0e39d465948bb322ac9736028b23cadc1c9032f60e766cb03

Contents?: true

Size: 353 Bytes

Versions: 3

Compression:

Stored size: 353 Bytes

Contents

module Basic101

  class RndFunction < Function

    def initialize
      @rand = 0
    end

    def name
      'RND'
    end

    def call(runtime, args)
      check_args args, [BasicNumeric]
      new_number = args.first.eval(runtime).to_f > 0
      if new_number
        @rand = runtime.rand
      end
      BasicFloat.new(@rand)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-0.4.0 lib/basic101/rnd_function.rb
basic101-0.2.0 lib/basic101/rnd_function.rb
basic101-0.1.0 lib/basic101/rnd_function.rb