Class: RTanque::Gui::DrawGroup
- Inherits:
-
Object
- Object
- RTanque::Gui::DrawGroup
- Includes:
- Enumerable
- Defined in:
- lib/rtanque/gui/draw_group.rb
Instance Method Summary collapse
- #draw ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(tick_group, &create_drawable) ⇒ DrawGroup
constructor
A new instance of DrawGroup.
Constructor Details
#initialize(tick_group, &create_drawable) ⇒ DrawGroup
Returns a new instance of DrawGroup.
6 7 8 9 10 11 |
# File 'lib/rtanque/gui/draw_group.rb', line 6 def initialize(tick_group, &create_drawable) @tick_group = tick_group @mapped_drawables = Hash.new do |h, tickable| h[tickable] = create_drawable.call(tickable) end end |
Instance Method Details
#draw ⇒ Object
23 24 25 26 27 |
# File 'lib/rtanque/gui/draw_group.rb', line 23 def draw self.each do |drawable| drawable.draw end end |
#each(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rtanque/gui/draw_group.rb', line 13 def each(&block) @tick_group.each do |tickable| if tickable.dead? @mapped_drawables.delete(tickable) else block.call(@mapped_drawables[tickable]) # This invokes @mapped_drawables's block if tickable not already in the hash end end end |