Class: Rufus::Lua::Function

A Lua function.

  require 'rubygems'
  require 'rufus/lua'

  s = Rufus::Lua::State.new

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

  f.call(2) # => 4.0

Constructor Summary

This class inherits a constructor from Rufus::Lua::Ref.

Public Visibility

Public Instance Method Summary

#call(*args)

Calls the Lua function.

Public Instance Methods Inherited from Rufus::Lua::Ref

free

Public Instance Method Details

call

public call(*args)

Calls the Lua function.

[View source]


91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rufus/lua/objects.rb', line 91

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)
end
Generated on Wednesday, September 30 2009 at 01:27:07 PM by YARD 0.2.3.5 (ruby-1.8.7).