Sha256: 96caee19eee9bc48a8b8ebe26e14f5fbd35e106c2201c3b92870573f9292da13

Contents?: true

Size: 818 Bytes

Versions: 3

Compression:

Stored size: 818 Bytes

Contents

require_relative '../repository/command_repository'
require_relative '../support/queue'
require_relative '../parsing/parser'

module Vedeu
  class Process
    def self.evaluate
      new.evaluate
    end

    def initialize; end

    def evaluate
      return false if no_input?

      fail StopIteration if stop_requested?

      Parser.parse(result) unless no_result?
    end

    private

    def stop_requested?
      result == :stop
    end

    def no_result?
      result.nil? || result.empty?
    end

    def no_input?
      input.nil? || input.empty?
    end

    def result
      @result ||= command.execute(*args) if command
    end

    def command
      @command ||= CommandRepository.by_input(input)
    end

    def input
      @input ||= Queue.dequeue
    end

    def args
      []
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.0.39 lib/vedeu/process/process.rb
vedeu-0.0.38 lib/vedeu/process/process.rb
vedeu-0.0.37 lib/vedeu/process/process.rb