Sha256: 633d6f3cacf6e34dfd55efcb6632c29f38b857cb6f5484fb2b1a5a778d7a5e76

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 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.9 lib/vedeu/process/commands.rb