zeitgeist.rb

来自「rcssserver3d Robocup 3D比赛官方指定平台」· RB 代码 · 共 64 行

RB
64
字号
## this is the init script of the Zeitgeist library# # here we perform the callback to zeitgeistdef method_missing(methId, *args)	str = methId.id2name	selectCall str, argsend# this method allows us to create new instance variables in class objects# we use class objects as 'namespaces'# createVariable can be used in two forms:# - 2 parameters: createVariable("myNamespace.myVarName", "myValue");# - 3 parameters: createVariable("myNamespace", "myVarName", "myValue");def createVariable (namespace, variable, value = nil)        # 2 parameters means the "namespace.variable", "value" form        if (value == nil)	        value = variable;	        # parse namespace into a namespace and varName pair	        periodIndex = namespace.index('.');                if (periodIndex != nil && periodIndex > 0)                        variable = namespace[(periodIndex+1)..-1];                        namespace = namespace[0..(periodIndex-1)];		else		        namespace = nil;		end	end          # here we have 3 parameters: namespace, variable, and value           if (namespace != nil)                eval <<-EOS                        class #{namespace}                        end                        class << #{namespace}                                attr_accessor :#{variable}                        end                        #{namespace}.#{variable} = value                EOS        endend# this is a proxy class for objects created with 'create' via the Zeitgeist# framework. It allows arbitrary methods to be called on the object and allows# for much nicer syntax, than the select-call paradigmclass ZeitgeistObject	# a pointer to the object represented by t	attr_reader :objPointer	def method_missing(methId, *args)		#print "Missing method", @objPointer, "->", methId.id2name, "\n"		str = methId.id2name		thisCall @objPointer, str, args	end	def initialize(objPointer)		#print "Creating new ZeitgeistObject ", objPointer, "\n"		@objPointer = objPointer	endend# set up some useful aliasesalias cd selectObject

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?