Welcome to mirror list, hosted at ThFree Co, Russian Federation.

doc.rb « navigation « gitlab « lib - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 97aa67757de81726bc6fc3dd8c423313868771bd (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
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

module Gitlab
  class Navigation
    class Doc
      def initialize(doc)
        @doc = doc
      end

      def title
        doc[:doc_title]
      end

      def external_url
        doc[:external_url]
      end

      def url
        doc[:doc_url]
      end

      def ee_only?
        doc[:ee_only]
      end

      def ee_tier
        doc[:ee_tier]
      end

      def has_children?
        !children.empty?
      end

      def children
        @children ||= doc.fetch(:docs, []).map { |nested_doc| Doc.new(nested_doc) }
      end

      private

      attr_reader :doc
    end
  end
end