Class: Build::Files::Paths
Overview
Represents an explicit list of file paths.
Constant Summary
Constants inherited from List
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Class Method Summary collapse
-
.directory(root, relative_paths) ⇒ Object
Create a paths list from a directory root and relative paths.
Instance Method Summary collapse
-
#count ⇒ Object
Get the count of paths in the list.
-
#each ⇒ Object
Iterate over all paths in the list.
-
#eql?(other) ⇒ Boolean
Check equality with another paths list.
-
#hash ⇒ Object
Compute the hash value for this paths list.
-
#initialize(list, roots = nil) ⇒ Paths
constructor
Initialize a paths list.
-
#inspect ⇒ Object
Generate a string representation for debugging.
-
#roots ⇒ Object
The list of roots for a given list of immutable files is also immutable, so we cache it for performance:.
-
#to_paths ⇒ Object
Return this paths list unchanged.
Methods inherited from List
#+, #-, #==, coerce, #copy, #create, #delete, #empty?, #exist?, #intersects?, #map, #rebase, #to_s, #touch, #with
Constructor Details
#initialize(list, roots = nil) ⇒ Paths
Initialize a paths list.
15 16 17 18 |
# File 'lib/build/files/paths.rb', line 15 def initialize(list, roots = nil) @list = Array(list).freeze @roots = roots end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
20 21 22 |
# File 'lib/build/files/paths.rb', line 20 def list @list end |
Class Method Details
.directory(root, relative_paths) ⇒ Object
Create a paths list from a directory root and relative paths.
71 72 73 74 75 76 77 |
# File 'lib/build/files/paths.rb', line 71 def self.directory(root, relative_paths) paths = relative_paths.collect do |path| Path.join(root, path) end self.new(paths, [root]) end |
Instance Method Details
#count ⇒ Object
Get the count of paths in the list.
29 30 31 |
# File 'lib/build/files/paths.rb', line 29 def count @list.count end |
#each ⇒ Object
Iterate over all paths in the list.
36 37 38 39 40 |
# File 'lib/build/files/paths.rb', line 36 def each return to_enum(:each) unless block_given? @list.each{|path| yield path} end |
#eql?(other) ⇒ Boolean
Check equality with another paths list.
45 46 47 |
# File 'lib/build/files/paths.rb', line 45 def eql?(other) self.class.eql?(other.class) and @list.eql?(other.list) end |
#hash ⇒ Object
Compute the hash value for this paths list.
51 52 53 |
# File 'lib/build/files/paths.rb', line 51 def hash @list.hash end |
#inspect ⇒ Object
Generate a string representation for debugging.
63 64 65 |
# File 'lib/build/files/paths.rb', line 63 def inspect "<Paths #{@list.inspect}>" end |
#roots ⇒ Object
The list of roots for a given list of immutable files is also immutable, so we cache it for performance:
23 24 25 |
# File 'lib/build/files/paths.rb', line 23 def roots @roots ||= super end |
#to_paths ⇒ Object
Return this paths list unchanged.
57 58 59 |
# File 'lib/build/files/paths.rb', line 57 def to_paths self end |