debian-mirror-gitlab/lib/gitlab/word_diff/segments/chunk.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
624 B
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# frozen_string_literal: true
# Chunk is a part of the line that starts with ` `, `-`, `+`
# Consecutive chunks build a line. Line that starts with `~` is an identifier of
# end of the line.
module Gitlab
module WordDiff
module Segments
class Chunk
def initialize(line)
@line = line
end
def removed?
line[0] == '-'
end
def added?
line[0] == '+'
end
def to_s
line[1..] || ''
end
def length
to_s.length
end
private
attr_reader :line
end
end
end
end