Class: LangGraphRB::Edge

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

Overview

Simple edge connecting two nodes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to) ⇒ Edge



6
7
8
9
# File 'lib/langgraph_rb/edge.rb', line 6

def initialize(from, to)
  @from = from.to_sym
  @to = to.to_sym
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



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

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



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

def to
  @to
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
# File 'lib/langgraph_rb/edge.rb', line 23

def ==(other)
  other.is_a?(Edge) && @from == other.from && @to == other.to
end

#inspectObject



19
20
21
# File 'lib/langgraph_rb/edge.rb', line 19

def inspect
  "#<Edge: #{to_s}>"
end

#route(state, context: nil) ⇒ Object



11
12
13
# File 'lib/langgraph_rb/edge.rb', line 11

def route(state, context: nil)
  [@to]
end

#to_sObject



15
16
17
# File 'lib/langgraph_rb/edge.rb', line 15

def to_s
  "#{@from} -> #{@to}"
end