Class: Build::Files::Difference
- Defined in:
- lib/build/files/difference.rb
Overview
Represents a list of files with exclusions applied.
Constant Summary
Constants inherited from List
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#-(list) ⇒ Object
Subtract additional files from this difference.
-
#each ⇒ Object
Iterate over files in the base list, excluding those in the exclusion list.
-
#freeze ⇒ Object
Freeze the difference list and its dependencies.
-
#include?(path) ⇒ Boolean
Check if the difference includes a specific path.
-
#initialize(list, excludes) ⇒ Difference
constructor
Initialize a difference list.
-
#inspect ⇒ Object
Generate a string representation for debugging.
-
#rebase(root) ⇒ Object
Rebase the difference to a new root.
Methods inherited from List
#+, #==, coerce, #copy, #create, #delete, #empty?, #exist?, #intersects?, #map, #roots, #to_paths, #to_s, #touch, #with
Constructor Details
#initialize(list, excludes) ⇒ Difference
Initialize a difference list.
15 16 17 18 |
# File 'lib/build/files/difference.rb', line 15 def initialize(list, excludes) @list = list @excludes = excludes end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
20 21 22 |
# File 'lib/build/files/difference.rb', line 20 def files @files end |
Instance Method Details
#-(list) ⇒ Object
Subtract additional files from this difference.
44 45 46 |
# File 'lib/build/files/difference.rb', line 44 def -(list) self.class.new(@list, Composite.new([@excludes, list])) end |
#each ⇒ Object
Iterate over files in the base list, excluding those in the exclusion list.
33 34 35 36 37 38 39 |
# File 'lib/build/files/difference.rb', line 33 def each return to_enum(:each) unless block_given? @list.each do |path| yield path unless @excludes.include?(path) end end |
#freeze ⇒ Object
Freeze the difference list and its dependencies.
23 24 25 26 27 28 |
# File 'lib/build/files/difference.rb', line 23 def freeze @list.freeze @excludes.freeze super end |
#include?(path) ⇒ Boolean
Check if the difference includes a specific path.
51 52 53 |
# File 'lib/build/files/difference.rb', line 51 def include?(path) @list.include?(path) and !@excludes.include?(path) end |
#inspect ⇒ Object
Generate a string representation for debugging.
64 65 66 |
# File 'lib/build/files/difference.rb', line 64 def inspect "<Difference #{@list.inspect} - #{@excludes.inspect}>" end |