Class: AIA::Directive
- Inherits:
-
PM::Directive
- Object
- PM::Directive
- AIA::Directive
- Defined in:
- lib/aia/directive.rb
Direct Known Subclasses
ConfigurationDirectives, ContextDirectives, ExecutionDirectives, ModelDirectives, TrakFlowDirectives, UtilityDirectives, WebAndFileDirectives
Constant Summary collapse
- DIRECTIVE_PREFIX =
'/'.freeze
Class Method Summary collapse
-
.build_dispatch_block(inst, method_name) ⇒ Object
---- Dispatch override ------------------------------------------------ AIA directive methods use (args_array, context_manager) convention, not (ctx, *args).
-
.help ⇒ Object
---- Help output ------------------------------------------------------ Application-level concern: formats help text using DIRECTIVE_PREFIX and all registered directive subclasses.
-
.state_setting!(*method_names) ⇒ Object
---- State-setting DSL ----------------------------------------------- Directives that mutate turn-state or set a mode flag (rather than returning text for the AI) should declare themselves here so that ChatLoop can ask the processor instead of hardcoding a name list.
- .state_setting_methods ⇒ Object
Class Method Details
.build_dispatch_block(inst, method_name) ⇒ Object
---- Dispatch override ------------------------------------------------ AIA directive methods use (args_array, context_manager) convention, not (ctx, *args). Override build_dispatch_block to adapt.
63 64 65 |
# File 'lib/aia/directive.rb', line 63 def build_dispatch_block(inst, method_name) proc { |_ctx, *args| inst.send(method_name, Array(args).flatten, nil) } end |
.help ⇒ Object
---- Help output ------------------------------------------------------ Application-level concern: formats help text using DIRECTIVE_PREFIX and all registered directive subclasses.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/aia/directive.rb', line 71 def help puts puts "Available Directives" puts "====================" puts total = 0 PM::Directive.directive_subclasses.each do |klass| next if klass.directive_descriptions.empty? cat = klass.category_name puts "#{cat}:" puts "-" * cat.length klass.directive_descriptions.each do |method_name, description| aliases = klass.directive_aliases[method_name] || [] alias_text = if aliases.any? " (aliases: #{aliases.map { |a| "#{DIRECTIVE_PREFIX}#{a}" }.join(', ')})" else "" end puts " #{DIRECTIVE_PREFIX}#{method_name}#{alias_text}" puts " #{description}" puts total += 1 end end puts "\nTotal: #{total} directives available" "" end |
.state_setting!(*method_names) ⇒ Object
---- State-setting DSL ----------------------------------------------- Directives that mutate turn-state or set a mode flag (rather than returning text for the AI) should declare themselves here so that ChatLoop can ask the processor instead of hardcoding a name list.
Usage (in a subclass body):
state_setting! :verify, :decompose, :concurrent, :conc
The names must match the directive method names (without the / prefix).
50 51 52 53 |
# File 'lib/aia/directive.rb', line 50 def state_setting!(*method_names) @state_setting_methods ||= [] @state_setting_methods.concat(method_names.map(&:to_s)) end |
.state_setting_methods ⇒ Object
55 56 57 |
# File 'lib/aia/directive.rb', line 55 def state_setting_methods @state_setting_methods || [] end |