Class: PathList
- Includes:
- Finder
- Defined in:
- lib/more/facets/pathlist.rb
Overview
PathList
A PathList is an array containing 1..n paths. It is useful to regroup paths and make lookups on them.
Usage
path = PathList.new(ENV['PATH'])
path.find 'env' #=> "/usr/bin/env"
# This is already done when including the library
$:.class #=> Array
$:.extend PathList::Finder
$:.find_ext = 'rb'
$:.find 'uri' #=> "/usr/lib/ruby/1.8/uri.rb"
Defined Under Namespace
Modules: Finder
Instance Attribute Summary
Attributes included from Finder
Instance Method Summary collapse
-
#initialize(paths, default_ext = nil) ⇒ PathList
constructor
A new instance of PathList.
- #to_s ⇒ Object
Methods included from Finder
Methods inherited from Array
#at_rand, #at_rand!, cast_from, #conjoin, #delete_unless, #delete_values, #delete_values_at, #each_iteration, #merge!, mutable_methods, #not_empty?, #only, #pad, #pad!, #pick, #pick!, #rand_index, #rand_subset, #restore_snapshot, #rotate, #rotate!, #select!, #shuffle, #shuffle!, #splice, #take_snapshot, #to_b, #to_console, #to_h, #to_path, #to_t
Methods included from Stackable
#peek, #poke, #pop, #pull, #push
Methods included from Indexable
#body, #ends, #first, #first!, #first=, #foot, #head, #index_of, #last, #last!, #last=, #mid, #middle, #pos, #range, #tail, #thru
Constructor Details
#initialize(paths, default_ext = nil) ⇒ PathList
Returns a new instance of PathList.
49 50 51 52 53 54 55 |
# File 'lib/more/facets/pathlist.rb', line 49 def initialize(paths, default_ext = nil) @find_ext = default_ext if paths.kind_of? String paths = paths.split(File::PATH_SEPARATOR) end super(paths) end |