aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/tag.rb
blob: a7c13b20026da577e4bd2f9267250dc895255dda (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
module Nuldoc
  Tag = Struct.new(:slug, :label, keyword_init: true) do
    LABELS = {
      'conference'   => 'カンファレンス',
      'cpp'          => 'C++',
      'cpp17'        => 'C++ 17',
      'note-to-self' => '備忘録',
      'php'          => 'PHP',
      'phpcon'       => 'PHP カンファレンス',
      'phperkaigi'   => 'PHPerKaigi',
      'python'       => 'Python',
      'python3'      => 'Python 3',
      'ruby'         => 'Ruby',
      'ruby3'        => 'Ruby 3',
      'rust'         => 'Rust',
      'vim'          => 'Vim',
    }

    def self.from_slug(slug)
      Tag.new(
        slug: slug,
        label: (LABELS[slug] || raise("No label for tag '#{slug}'")),
      )
    end
  end
end