Class: Moult::Diff::ChangedFile
- Inherits:
-
Struct
- Object
- Struct
- Moult::Diff::ChangedFile
- Defined in:
- lib/moult/diff.rb
Overview
One changed file. status is git's single-letter code (A/M/D/R/C/...);
line_ranges are the new-side changed line ranges (empty for a deletion, a
pure-deletion hunk, or a content-less rename).
Instance Attribute Summary collapse
-
#line_ranges ⇒ Object
Returns the value of attribute line_ranges.
-
#path ⇒ Object
Returns the value of attribute path.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#changed_line?(line) ⇒ Boolean
Does
linefall on a changed/added line of this file?. -
#changed_range?(lo, hi) ⇒ Boolean
Does the inclusive line range [lo, hi] intersect any changed range?.
Instance Attribute Details
#line_ranges ⇒ Object
Returns the value of attribute line_ranges
24 25 26 |
# File 'lib/moult/diff.rb', line 24 def line_ranges @line_ranges end |
#path ⇒ Object
Returns the value of attribute path
24 25 26 |
# File 'lib/moult/diff.rb', line 24 def path @path end |
#status ⇒ Object
Returns the value of attribute status
24 25 26 |
# File 'lib/moult/diff.rb', line 24 def status @status end |
Instance Method Details
#changed_line?(line) ⇒ Boolean
Does line fall on a changed/added line of this file?
26 27 28 |
# File 'lib/moult/diff.rb', line 26 def changed_line?(line) line_ranges.any? { |r| r.cover?(line) } end |
#changed_range?(lo, hi) ⇒ Boolean
Does the inclusive line range [lo, hi] intersect any changed range?
31 32 33 |
# File 'lib/moult/diff.rb', line 31 def changed_range?(lo, hi) line_ranges.any? { |r| r.begin <= hi && r.end >= lo } end |