Class: GADDAG::Arc
- Inherits:
-
Object
- Object
- GADDAG::Arc
- Defined in:
- lib/gaddag/arc.rb
Overview
Represents an arc pointing to a destination node with optional final letters
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
The destination node.
-
#final_letters ⇒ Object
readonly
A set of letters which form a word after being appended to the letter path.
Instance Method Summary collapse
-
#add_final_letter(letter) ⇒ Object
Adds a final letter to the arc.
-
#final_paths ⇒ Array<Path>
Returns all paths starting at this arc that are final.
-
#initialize(destination) ⇒ Arc
constructor
Initializes a GADDAG arc.
Constructor Details
#initialize(destination) ⇒ Arc
Initializes a GADDAG arc
22 23 24 25 |
# File 'lib/gaddag/arc.rb', line 22 def initialize(destination) @destination = destination @final_letters = Set.new end |
Instance Attribute Details
#destination ⇒ Object (readonly)
The destination node
10 11 12 |
# File 'lib/gaddag/arc.rb', line 10 def destination @destination end |
#final_letters ⇒ Object (readonly)
A set of letters which form a word after being appended to the letter path
13 14 15 |
# File 'lib/gaddag/arc.rb', line 13 def final_letters @final_letters end |
Instance Method Details
#add_final_letter(letter) ⇒ Object
Adds a final letter to the arc. A final letter is a letter that, when appended to the letter path, forms a valid word.
30 31 32 |
# File 'lib/gaddag/arc.rb', line 30 def add_final_letter(letter) @final_letters.add(letter) end |