Class: Mooncell::CLI::Commands::Registry Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/mooncell/cli/commands/registry.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Command Registry

Since:

  • 0.1.0

Defined Under Namespace

Classes: Node

Instance Method Summary collapse

Constructor Details

#initializeRegistry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Registry.

Since:

  • 0.1.0



24
25
26
# File 'lib/mooncell/cli/commands/registry.rb', line 24

def initialize
  @root = Node.new
end

Instance Method Details

#add(name, command = nil, aliases: [], app_only: false, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



30
31
32
# File 'lib/mooncell/cli/commands/registry.rb', line 30

def add(name, command = nil, aliases: [], app_only: false, &block)
  @root.add(name, command, aliases: aliases, app_only: app_only, &block)
end

#get(arguments) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mooncell/cli/commands/registry.rb', line 36

def get(arguments)
  node = @root

  arguments.each do |token|
    current = node.lookup(token)
    return node if current.nil? && node.leaf?

    node = current
  end

  node
end