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

tab_width.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d33723a2106ef7311fcc2e08d0059d7c1f9aa5b0 (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
# frozen_string_literal: true

module Gitlab
  module TabWidth
    extend self

    MIN = 1
    MAX = 12
    DEFAULT = 8

    def css_class_for_user(user)
      return css_class_for_value(DEFAULT) unless user

      css_class_for_value(user.tab_width)
    end

    private

    def css_class_for_value(value)
      raise ArgumentError unless in_range?(value)

      "tab-width-#{value}"
    end

    def in_range?(value)
      (MIN..MAX).cover?(value)
    end
  end
end