Class: PandaCanvas::DrawingCleanRoom
- Inherits:
-
Object
- Object
- PandaCanvas::DrawingCleanRoom
- Defined in:
- lib/panda_canvas/drawing_clean_room.rb
Overview
DrawingCleanRoom is used to capture and store method calls for delayed execution.
Constant Summary collapse
- FLUSH =
Signature for the
flushmethod. This method is used to stop calculation and draw the frame. [:flush].freeze
Instance Method Summary collapse
-
#calls ⇒ Object
Returns an array of captured method calls.
-
#initialize ⇒ DrawingCleanRoom
constructor
Initializes the clean object for method call capturing.
-
#method_missing(sym, *args) ⇒ Object
Capures and stores all missing method calls in the instance.
Constructor Details
#initialize ⇒ DrawingCleanRoom
Initializes the clean object for method call capturing.
18 19 20 |
# File 'lib/panda_canvas/drawing_clean_room.rb', line 18 def initialize @_calls = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
Capures and stores all missing method calls in the instance.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/panda_canvas/drawing_clean_room.rb', line 23 def method_missing(sym, *args) if sym == :flush @_calls << FLUSH elsif (DrawingMethods::CANVAS_CALLS.include? sym) || (Gosu::Image.public_instance_methods.include? sym) @_calls << [sym, *args] else super end end |
Instance Method Details
#calls ⇒ Object
Returns an array of captured method calls. A flush is appended at the end.
13 14 15 |
# File 'lib/panda_canvas/drawing_clean_room.rb', line 13 def calls @_calls + [FLUSH] end |