Class: WhirledPeas::Command::Play::ApplicationPlayer

Inherits:
Object
  • Object
show all
Defined in:
lib/whirled_peas/command/play.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_config_file, config, logger) ⇒ ApplicationPlayer

Returns a new instance of ApplicationPlayer.



14
15
16
17
18
# File 'lib/whirled_peas/command/play.rb', line 14

def initialize(app_config_file, config, logger)
  @app_config_file = app_config_file
  @config = config
  @logger = logger
end

Instance Method Details

#playObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/whirled_peas/command/play.rb', line 20

def play
  require app_config_file

  require 'whirled_peas/animator/renderer_consumer'
  require 'whirled_peas/animator/producer'
  require 'whirled_peas/device/screen'
  require 'whirled_peas/utils/ansi'

  Utils::Ansi.with_screen do |width, height|
    consumer = Animator::RendererConsumer.new(
      WhirledPeas.config.template_factory,
      Device::Screen.new,
      width,
      height
    )
    Animator::Producer.produce(consumer) do |producer|
      config.application.start(producer)
    end
  end
rescue LoadError => e
  puts e
  puts e.backtrace.join("\n")
  exit(1)
end