summaryrefslogtreecommitdiff
path: root/lib/gitlab/github_import/markdown_text.rb
blob: b25c4f7becf69280ecd266e483eab8056aa14b46 (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
# frozen_string_literal: true

module Gitlab
  module GithubImport
    class MarkdownText
      attr_reader :text, :author, :exists

      def self.format(*args)
        new(*args).to_s
      end

      # text - The Markdown text as a String.
      # author - An instance of `Gitlab::GithubImport::Representation::User`
      # exists - Boolean that indicates the user exists in the GitLab database.
      def initialize(text, author, exists = false)
        @text = text
        @author = author
        @exists = exists
      end

      def to_s
        if exists
          text
        else
          "*Created by: #{author.login}*\n\n#{text}"
        end
      end
    end
  end
end