Class: LangGraphRB::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/langgraph_rb/command.rb

Overview

Command combines a state update with a routing decision

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#gotoObject (readonly)

Returns the value of attribute goto.



4
5
6
# File 'lib/langgraph_rb/command.rb', line 4

def goto
  @goto
end

#updateObject (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

#inspectObject



30
31
32
# File 'lib/langgraph_rb/command.rb', line 30

def inspect
  to_s
end

#to_sObject



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