Sha256: 39bcccc6de3c289d96194ebae6e3b2c336af9453505421a96b6da0c234e133dd

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

module Vedeu
  class Interface
    attr_accessor :id, :active, :attributes, :result, :name, :geometry

    class << self
      def create(attributes = {})
        new(attributes).create
      end
    end

    def initialize(attributes = {})
      @attributes = attributes || {}
      @name       = attributes[:name]
      @active     = false
      @geometry   = Geometry.new(attributes[:geometry])
    end

    def create
      InterfaceRepository.create(self)

      InterfaceRepository.activate(self.name)

      self
    end

    def origin(index = 0)
      Position.set(geometry.vy(index), geometry.vx)
    end

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

    def input
      raise Collapse if evaluate == :stop
    end

    def output
      Compositor.arrange(@result, self) unless @result.nil? || @result.empty?
    end

    private

    def evaluate
      @result = Input.evaluate(read)
    end

    def read
      Terminal.input
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.11 lib/vedeu/repository/interface.rb