Class: PirateGame::Animation

Inherits:
Shoes::Animation
  • Object
show all
Defined in:
lib/pirate_game/animation.rb

Overview

An animation that resets the client application if a DRb::DRbConnError is raised during animation.

Instance Method Summary collapse

Constructor Details

#initialize(app, opts, blk) ⇒ Animation

See Shoes::Animation for details

[View source]

12
13
14
15
16
# File 'lib/pirate_game/animation.rb', line 12

def initialize app, opts, blk
  blk = wrap_block blk

  super app, opts, blk
end

Instance Method Details

#wrap_block(block) ⇒ Object

Wraps block in an exception handler that switches to the select_game_screen.

[View source]

22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pirate_game/animation.rb', line 22

def wrap_block block # :nodoc:
  proc do |*args|
    begin
      block.call(*args)
    rescue DRb::DRbConnError
      @app.state = :select_game

      @app.select_game_screen
    end
  end
end