def on_learn(obj=nil, &block)
      @on_learn_obj = obj
      @on_learn = Proc.new { |device, obj_ptr, int_data, data_length, code_info|
		data = []
		data_length.times { |i|
			data[i] = int_data[i].get_uchar(0).to_s(16)
		}
		
		code_info_struct = IR_code_info.new(code_info)	
				
	    yield self, data, data_length, code_info_struct, object_for(obj_ptr)
	}
      Klass.set_OnLearn_Handler(@handle, @on_learn, pointer_for(obj))
    end
def on_learn(obj=nil, &block)
      @on_learn_obj = obj
      @on_learn = Proc.new { |device, obj_ptr, int_data, data_length, code_info|
		data = []
		data_length.times { |i|
			data[i] = int_data[i].get_uchar(0).to_s(16)
		}
		
		code_info_struct = IR_code_info.new(code_info)	
				
	    yield self, data, data_length, code_info_struct, object_for(obj_ptr)
	}
      Klass.set_OnLearn_Handler(@handle, @on_learn, pointer_for(obj))
    end
Sets a learn handler callback function. This is called when a new code has been learned. This generally requires the button to be held down for a second or two.

 @param [String] obj Object to pass to the callback function. This is optional.
 @param [Proc] Block When the callback is executed, the device and object are yielded to this block.
 @example
   ir.on_learn do |device, data, data_length, code_info, obj|
     puts "Code #{data} learnt"
   end
 As this runs in it's own thread, be sure that all errors are properly handled or the thread will halt and not fire any more.
 @return [Boolean] returns true or raises an error