summaryrefslogtreecommitdiff
path: root/lib/gitlab/git/blob_snippet.rb
blob: 68116e775c68dd1168cac372d035b9b6d5b0b7c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Gitaly note: JV: no RPC's here.

module Gitlab
  module Git
    class BlobSnippet
      include Linguist::BlobHelper

      attr_accessor :ref
      attr_accessor :lines
      attr_accessor :filename
      attr_accessor :startline

      def initialize(ref, lines, startline, filename)
        @ref, @lines, @startline, @filename = ref, lines, startline, filename
      end

      def data
        lines&.join("\n")
      end

      def name
        filename
      end

      def size
        data.length
      end

      def mode
        nil
      end
    end
  end
end