Class: LangGraphRB::Command
- Inherits:
-
Object
- Object
- LangGraphRB::Command
- Defined in:
- lib/langgraph_rb/command.rb
Overview
Command combines a state update with a routing decision
Instance Attribute Summary collapse
-
#goto ⇒ Object
readonly
Returns the value of attribute goto.
-
#update ⇒ Object
readonly
Returns the value of attribute update.
Class Method Summary collapse
- .goto(destination) ⇒ Object
- .update(state_delta) ⇒ Object
- .update_and_goto(state_delta, destination) ⇒ Object
Instance Method Summary collapse
-
#initialize(update: nil, goto: nil) ⇒ Command
constructor
A new instance of Command.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(update: nil, goto: nil) ⇒ Command
Returns a new instance of Command.
6 7 8 9 |
# File 'lib/langgraph_rb/command.rb', line 6 def initialize(update: nil, goto: nil) @update = update || {} @goto = goto end |
Instance Attribute Details
#goto ⇒ Object (readonly)
Returns the value of attribute goto.
4 5 6 |
# File 'lib/langgraph_rb/command.rb', line 4 def goto @goto end |
#update ⇒ Object (readonly)
Returns the value of attribute update.
4 5 6 |
# File 'lib/langgraph_rb/command.rb', line 4 def update @update end |
Class Method Details
.goto(destination) ⇒ Object
15 16 17 |
# File 'lib/langgraph_rb/command.rb', line 15 def self.goto(destination) new(goto: destination) end |
.update(state_delta) ⇒ Object
11 12 13 |
# File 'lib/langgraph_rb/command.rb', line 11 def self.update(state_delta) new(update: state_delta) end |
.update_and_goto(state_delta, destination) ⇒ Object
19 20 21 |
# File 'lib/langgraph_rb/command.rb', line 19 def self.update_and_goto(state_delta, destination) new(update: state_delta, goto: destination) end |
Instance Method Details
#inspect ⇒ Object
30 31 32 |
# File 'lib/langgraph_rb/command.rb', line 30 def inspect to_s end |
#to_s ⇒ Object
23 24 25 26 27 28 |
# File 'lib/langgraph_rb/command.rb', line 23 def to_s parts = [] parts << "update: #{@update.inspect}" unless @update.empty? parts << "goto: #{@goto}" if @goto "#<Command #{parts.join(', ')}>" end |