Sha256: 9310086d121af198ff8e2614dce5b2c3a5b97a8d7b2ae089c5a162fa91cf5569
Contents?: true
Size: 718 Bytes
Versions: 5
Compression:
Stored size: 718 Bytes
Contents
module GitDiff class RangeInfo attr_reader :original_range, :new_range, :header module ClassMethods def from_string(string) if(range_data = extract_hunk_range_data(string)) new(*range_data.captures) end end def extract_hunk_range_data(string) /@@ \-(.+) \+(.+) @@(.*)/.match(string) end end extend ClassMethods def initialize(original_range, new_range, header) @original_range = LineNumberRange.from_string(original_range) @new_range = LineNumberRange.from_string(new_range) @header = header.strip end def to_s "@@ #{original_range.to_s(:-)} #{new_range.to_s(:+)} @@ #{header}".strip end end end
Version data entries
5 entries across 5 versions & 1 rubygems