Sha256: 80259e5e074403737797ce8c563aa3ed6dd99add10d017ccc75f04c4751d4fcd

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

module Vedeu
  class NotImplementedError < StandardError; end

  class Interface
    def initialize(options = {})
      @options = options
    end

    def initial_state
      raise NotImplementedError, 'Subclasses implement this method.'
    end

    def event_loop
      while true do
        command = input

        break if command == :stop

        output(command)
      end
    end

    def input
      evaluate
    end

    def output(command)
      Compositor.write(command, self)
    end

    def geometry
      @geometry ||= Geometry.new(options[:geometry])
    end

    private

    attr_reader :options

    def evaluate
      Commands.execute(read)
    end

    def read
      Terminal.input
    end

    def options
      defaults.merge!(@options)
    end

    def defaults
      {
        geometry: {}
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.7 lib/vedeu/interface/interface.rb