class Rufus::Lua::Function

A Lua function.

require 'rufus/lua'

s = Rufus::Lua::State.new

f = s.eval(%{
  return function (x)
    return 2 * x
  end
})

f.call(2) # => 4.0

Public Instance Methods

call(*args) click to toggle source

Calls the Lua function.

# File lib/rufus/lua/objects.rb, line 67
def call(*args)

  bottom = stack_top

  load_onto_stack
    # load function on stack

  args.each { |arg| stack_push(arg) }
    # push arguments on stack

  pcall(bottom, args.length, nil, nil, nil)
end