Class: Mooncell::CLI::Commands::Registry::Node Private
- Inherits:
-
Object
- Object
- Mooncell::CLI::Commands::Registry::Node
- 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.
Instance Attribute Summary collapse
- #command ⇒ Object readonly private
- #name ⇒ Object readonly private
Instance Method Summary collapse
- #add(name, command = nil, aliases: [], app_only: false, &block) ⇒ Object private
-
#app_only? ⇒ Boolean
private
Is only for application.
- #call(*args) ⇒ Object private
-
#initialize(name = nil, command = nil, app_only: false) ⇒ Node
constructor
private
A new instance of Node.
-
#leaf? ⇒ Boolean
private
Is the end of command.
- #lookup(name) ⇒ Object private
Constructor Details
#initialize(name = nil, command = nil, app_only: false) ⇒ Node
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 Node.
56 57 58 59 60 61 |
# File 'lib/mooncell/cli/commands/registry.rb', line 56 def initialize(name = nil, command = nil, app_only: false) @name = name @command = command @children = {} @app_only = app_only end |
Instance Attribute Details
#command ⇒ Object (readonly)
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.
52 53 54 |
# File 'lib/mooncell/cli/commands/registry.rb', line 52 def command @command end |
#name ⇒ Object (readonly)
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.
52 53 54 |
# File 'lib/mooncell/cli/commands/registry.rb', line 52 def name @name 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.
80 81 82 83 84 |
# File 'lib/mooncell/cli/commands/registry.rb', line 80 def add(name, command = nil, aliases: [], app_only: false, &block) node = Node.new(name, command || block, app_only: app_only) @children[name] = node aliases.each { |token| @children[token] = node } end |
#app_only? ⇒ Boolean
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 is only for application.
67 68 69 |
# File 'lib/mooncell/cli/commands/registry.rb', line 67 def app_only? @app_only == true end |
#call(*args) ⇒ 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.
94 95 96 97 98 99 100 |
# File 'lib/mooncell/cli/commands/registry.rb', line 94 def call(*args) return if app_only? && !Commands.app_initialized? return if command.nil? return command.call(*args) if command.is_a?(Proc) command.new.call(*args) end |
#leaf? ⇒ Boolean
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 is the end of command.
74 75 76 |
# File 'lib/mooncell/cli/commands/registry.rb', line 74 def leaf? @children.empty? end |
#lookup(name) ⇒ 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.
88 89 90 |
# File 'lib/mooncell/cli/commands/registry.rb', line 88 def lookup(name) @children[name] end |