Class: RubyCoded::Commands::CommandDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_coded/commands/command_definition.rb

Overview

Normalized command metadata shared by core, plugin, and markdown commands.

Constant Summary collapse

ATTRIBUTES =
%i[name description handler source usage content path].freeze

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ CommandDefinition

Returns a new instance of CommandDefinition.



11
12
13
# File 'lib/ruby_coded/commands/command_definition.rb', line 11

def initialize(**attrs)
  ATTRIBUTES.each { |name| instance_variable_set(ivar(name), attrs[name]) }
end

Instance Method Details

#executable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ruby_coded/commands/command_definition.rb', line 19

def executable?
  !@handler.nil? || markdown?
end

#markdown?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ruby_coded/commands/command_definition.rb', line 15

def markdown?
  @source == :markdown
end