class LittleGhost::PathSet
PathSet keeps prompt or skill lookup roots in deterministic search order. It is immutable, so appending a path does not change a running configuration.
Attributes
The immutable Lookup::Root values in search order.
Public Class Methods
Source
# File lib/little_ghost/path_set.rb, line 13 def initialize(paths = []) @paths = Array(paths).map { |path| path.is_a?(Lookup::Root) ? path : Lookup::Root.new(path:) }.freeze end
Accepts path strings and Lookup::Root objects.
Public Instance Methods
Source
# File lib/little_ghost/path_set.rb, line 28 def +(other) PathSet.new([*paths, *Array(other)]) end
Appends other in a new path set; neither input is mutated.
Source
# File lib/little_ghost/path_set.rb, line 18 def each(&block) paths.each(&block) end
Yields each Lookup::Root in order.
Source
# File lib/little_ghost/path_set.rb, line 23 def to_a paths.dup end
Copies the roots into a mutable array.