Class: LittleGhost::PathSet
- Inherits:
-
Object
- Object
- LittleGhost::PathSet
- Includes:
- Enumerable
- Defined in:
- lib/little_ghost/path_set.rb
Overview
PathSet keeps prompt or skill lookup roots in deterministic search order. It is immutable, so appending a path does not change a running configuration.
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
The immutable Lookup::Root values in search order.
Instance Method Summary collapse
-
#+(other) ⇒ Object
Appends
otherin a new path set; neither input is mutated. -
#each(&block) ⇒ Object
Yields each Lookup::Root in order.
-
#initialize(paths = []) ⇒ PathSet
constructor
Accepts path strings and Lookup::Root objects.
-
#to_a ⇒ Object
Copies the roots into a mutable array.
Constructor Details
Instance Attribute Details
#paths ⇒ Object (readonly)
The immutable Lookup::Root values in search order.
10 11 12 |
# File 'lib/little_ghost/path_set.rb', line 10 def paths @paths end |
Instance Method Details
#+(other) ⇒ Object
Appends other in a new path set; neither input is mutated.
28 29 30 |
# File 'lib/little_ghost/path_set.rb', line 28 def +(other) PathSet.new([*paths, *Array(other)]) end |
#each(&block) ⇒ Object
Yields each Lookup::Root in order.
18 19 20 |
# File 'lib/little_ghost/path_set.rb', line 18 def each(&block) paths.each(&block) end |
#to_a ⇒ Object
Copies the roots into a mutable array.
23 24 25 |
# File 'lib/little_ghost/path_set.rb', line 23 def to_a paths.dup end |