Sha256: fddfda08c2a16b77f9ea0014dde7458f0de059967fb33f7c6359aaf73ff1600a

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

module Joyce
  class Application
    def initialize(headless: false)
      @headless = headless
    end

    def setup
      # ...
    end

    def tick
      # ...
    end

    def launch
      sim.conduct!
      setup
      window.show
      self
    end

    def fire(cmd)
      sim.fire(cmd)
    end

    def received_events
      sim.received_events
    end

    def sim
      @simulation ||= RemoteSim.current
    end

    def view
      @view ||= construct_view
    end

    def window
      @window ||= @headless ? NullWindow.new(self) : ApplicationWindow.new(self)
    end

    private
    def construct_view
      self.class.view_class.new(self)
    end

    class << self
      attr_reader :view_class
      def viewed_with(view_class)
        @view_class ||= view_class
        self
      end

      def kickstart!(headless: false)
        app = new(headless: headless)
        app.launch
        app
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joyce-0.1.3 lib/joyce/application.rb
joyce-0.1.2 lib/joyce/application.rb