class GADDAG::Arc
Represents an arc pointing to a destination node with optional final letters
Attributes
destination[R]
The destination node
final_letters[R]
A set of letters which form a word after being appended to the letter path
Public Class Methods
new(destination)
click to toggle source
Initializes a GADDAG
arc @param destination [Node] the destination node @return [Arc]
# File lib/gaddag/arc.rb, line 22 def initialize(destination) @destination = destination @final_letters = Set.new end
Public Instance Methods
add_final_letter(letter)
click to toggle source
Adds a final letter to the arc. A final letter is a letter that, when appended to the letter path, forms a valid word. @param letter [String] the letter that is to be marked as final
# File lib/gaddag/arc.rb, line 30 def add_final_letter(letter) @final_letters.add(letter) end
final_paths()
click to toggle source
Returns all paths starting at this arc that are final @return [Array<Path>] a list of final paths that start at this arc
# File lib/gaddag/arc.rb, line 36 def final_paths final_letters.map { |fl| Path.new([fl]) } + destination.final_paths end