Class: Proc
Overview
Proc#bind is defined if it does not exist already
Instance Method Summary collapse
-
#bind(object) ⇒ Method
Proc#bind is defined if it does not exist already.
-
#while(&action) ⇒ NilClass
An overloadable while loop.
-
#while_with_gcc(&action) ⇒ NilClass
Overloaded while loop for handling compilation.
Instance Method Details
#bind(object) ⇒ Method
Proc#bind is defined if it does not exist already
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/multiarray.rb', line 56 def bind( object ) block, time = self, Time.now ( class << object; self end ).class_eval do method_name = "__bind_#{time.to_i}_#{time.usec}" define_method method_name, &block method = instance_method method_name remove_method method_name method end.bind object end |
#while(&action) ⇒ NilClass
An overloadable while loop
76 77 78 79 |
# File 'lib/multiarray.rb', line 76 def while( &action ) action.call while call.get nil end |
#while_with_gcc(&action) ⇒ NilClass
Overloaded while loop for handling compilation
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/multiarray/gccfunction.rb', line 205 def while_with_gcc( &action ) function = Thread.current[ :function ] if function function << "#{function.indent}while ( 1 ) {\n" function.indent_offset +1 function << "#{function.indent}if ( !( #{call.get}) ) break;\n" action.call function.indent_offset -1 function << "#{function.indent}}\n" nil else while_without_gcc &action end end |