Class: QuietQuality::ChangedFiles
- Inherits:
-
Object
- Object
- QuietQuality::ChangedFiles
- Defined in:
- lib/quiet_quality/changed_files.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #file(path) ⇒ Object
- #include?(path) ⇒ Boolean
-
#initialize(files) ⇒ ChangedFiles
constructor
A new instance of ChangedFiles.
- #merge(other) ⇒ Object
- #paths ⇒ Object
Constructor Details
#initialize(files) ⇒ ChangedFiles
Returns a new instance of ChangedFiles.
5 6 7 |
# File 'lib/quiet_quality/changed_files.rb', line 5 def initialize(files) @files = files end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
3 4 5 |
# File 'lib/quiet_quality/changed_files.rb', line 3 def files @files end |
Instance Method Details
#file(path) ⇒ Object
13 14 15 |
# File 'lib/quiet_quality/changed_files.rb', line 13 def file(path) files_by_path.fetch(path, nil) end |
#include?(path) ⇒ Boolean
17 18 19 |
# File 'lib/quiet_quality/changed_files.rb', line 17 def include?(path) files_by_path.include?(path) end |
#merge(other) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/quiet_quality/changed_files.rb', line 21 def merge(other) merged_files = [] (files + other.files) .group_by(&:path) .each_pair { |_path, pfiles| merged_files << pfiles.reduce(&:merge) } self.class.new(merged_files) end |
#paths ⇒ Object
9 10 11 |
# File 'lib/quiet_quality/changed_files.rb', line 9 def paths @_paths ||= files.map(&:path) end |