Class: Agents::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/agents/agent.rb

Direct Known Subclasses

Dispatcher, EchoAgent, EchoGptAgent, GptAgent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actions: []) ⇒ Agent

Returns a new instance of Agent.



5
6
7
# File 'lib/agents/agent.rb', line 5

def initialize(actions: [])
  @actions = actions
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



3
4
5
# File 'lib/agents/agent.rb', line 3

def actions
  @actions
end

Instance Method Details

#handle(request:) ⇒ Response

Returns response.

Parameters:

Returns:



11
12
13
# File 'lib/agents/agent.rb', line 11

def handle(request:)
  Response.new("Sorry, this agent doesn't know how to handle requests.")
end

#register(action:) ⇒ Object



15
16
17
# File 'lib/agents/agent.rb', line 15

def register(action:)
  @actions << action
end

#unregister(action:) ⇒ Object



19
20
21
# File 'lib/agents/agent.rb', line 19

def unregister(action:)
  @actions.delete(action)
end