Sha256: 73dee9d1f0f231560d990d6c18e6514659a7c40bd76d98f355f754f737fb4cc2

Contents?: true

Size: 599 Bytes

Versions: 3

Compression:

Stored size: 599 Bytes

Contents

module Vedeu
  module Commands
    extend self

    def define(&block)
      if block_given?
        yield self
      else
        self
      end
    end

    def execute(command = "")
      commands.fetch(command).call if exists?(command)
    end

    def list
      commands.inspect
    end

    def add(name, klass, args = [], options = {})
      commands.merge!(Command.define(name, klass, args, options))
    end

    private

    def exists?(command)
      commands.fetch(command, false)
    end

    def commands
      @commands ||= { 'exit' => Proc.new { Exit.dispatch } }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.0.8 lib/vedeu/process/commands.rb
vedeu-0.0.7 lib/vedeu/process/commands.rb
vedeu-0.0.6 lib/vedeu/process/commands.rb