Sha256: d186a40c1a6feab256be4c7764216b931dba75ac8ec0a72d4778e4022c05669d

Contents?: true

Size: 907 Bytes

Versions: 6

Compression:

Stored size: 907 Bytes

Contents

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

    def initialize; end

    def evaluate
      fail Collapse if result == :stop

      Compositor.arrange(result) unless no_result?
    end

    private

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

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

    def command
      @command ||= find_by_keypress || find_by_keyword
    end

    def find_by_keypress
      CommandRepository.by_keypress(input) if keypress?
    end

    def find_by_keyword
      CommandRepository.by_keyword(input) if keyword?
    end

    def keypress?
      input? && input.size == 1
    end

    def keyword?
      input? && input.size > 1
    end

    def input?
      !!(input)
    end

    def input
      @input ||= Queue.dequeue
    end

    def args
      []
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.0.24 lib/vedeu/process/process.rb
vedeu-0.0.23 lib/vedeu/process/process.rb
vedeu-0.0.22 lib/vedeu/process/process.rb
vedeu-0.0.21 lib/vedeu/process/process.rb
vedeu-0.0.20 lib/vedeu/process/process.rb
vedeu-0.0.19 lib/vedeu/process/process.rb