Class: Proc

Inherits:
Object
  • Object
show all
Defined in:
lib/profligacy/swing.rb

Overview

Modifications to Proc to make the Runnable and Listener conversion easy.

Instance Method Summary collapse

Instance Method Details

#to_listener(action) ⇒ Object

Takes this proc and converts it to an ListenerProc based on the action name. The name should be one in Profligacy::Listeners and is based on the add_blah_listener method on that component. So, if you need a ChangeListener you do:

proc {|t,e| puts t }.to_listener(:change)

The two parameters are a symbol for the method that Java called on this, and then the event argument.



217
218
219
# File 'lib/profligacy/swing.rb', line 217

def to_listener(action)
  Profligacy::Swing::Listeners.const_get("#{action.to_s.capitalize}ListenerProc").new &self
end

#to_runnableObject

Converts this Proc to a RunnableProc which implements the Runnable interface.



222
223
224
# File 'lib/profligacy/swing.rb', line 222

def to_runnable
  Profligacy::Swing::RunnableProc.new &self
end