Sha256: 39ff4615f730ff4048edee956e83fbf968cc95da190d15fbf45502fc82df6587

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

require_relative 'abs_function'
require_relative 'asc_function'
require_relative 'chr_function'
require_relative 'int_function'
require_relative 'left_function'
require_relative 'len_function'
require_relative 'mid_function'
require_relative 'right_function'
require_relative 'rnd_function'
require_relative 'str_function'
require_relative 'tab_function'
require_relative 'val_function'

module Basic101

  class Functions

    def initialize(functions = BuiltInFunctions.make)
      @functions = {}
      functions.each do |function|
        add_function function
      end
    end

    def call(runtime, identifier, argument_values)
      @functions[identifier.to_s].call(runtime, argument_values)
    end

    def add_function(function)
      @functions[function.name] = function
    end

    def has_function?(name)
      @functions.has_key?(name.to_s)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

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