Sha256: eda99cb96fc62bfd615294f86e4af0b7d6c1e743b500da42512e2ef8c10e2811

Contents?: true

Size: 599 Bytes

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.10 lib/vedeu/process/commands.rb