Sha256: 4c34321c8c754fd987548a2ce8e5b81bdcff4c233e70bcbe9ee4fe58cf8f07c0

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 Bytes

Contents

module Vedeu
  class NotImplementedError < StandardError; end

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

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

    def input
      raise Collapse if evaluate == :stop
    end

    def output
      write
    end

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

    private

    attr_reader :options

    def evaluate
      @output = Commands.execute(read)
    end

    def read
      Terminal.input
    end

    def write
      Compositor.arrange(@output, self)
    end

    def options
      defaults.merge!(@options)
    end

    def defaults
      {
        geometry: {
                    y:      1,
                    x:      1,
                    width:  :auto,
                    height: :auto
                  }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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