Class: Gitlab::Badge::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/badge/template.rb

Overview

Abstract template class for badges

Direct Known Subclasses

Coverage::Template, Pipeline::Template

Constant Summary collapse

MAX_KEY_TEXT_SIZE =
64
MAX_KEY_WIDTH =
512

Instance Method Summary collapse

Constructor Details

#initialize(badge) ⇒ Template

Returns a new instance of Template.


12
13
14
15
# File 'lib/gitlab/badge/template.rb', line 12

def initialize(badge)
  @entity = badge.entity
  @status = badge.status
end

Instance Method Details

#key_colorObject


37
38
39
# File 'lib/gitlab/badge/template.rb', line 37

def key_color
  '#555'
end

#key_textObject

Raises:

  • (NotImplementedError)

17
18
19
# File 'lib/gitlab/badge/template.rb', line 17

def key_text
  raise NotImplementedError
end

#key_text_anchorObject


41
42
43
# File 'lib/gitlab/badge/template.rb', line 41

def key_text_anchor
  key_width / 2
end

#key_widthObject

Raises:

  • (NotImplementedError)

25
26
27
# File 'lib/gitlab/badge/template.rb', line 25

def key_width
  raise NotImplementedError
end

#value_colorObject

Raises:

  • (NotImplementedError)

33
34
35
# File 'lib/gitlab/badge/template.rb', line 33

def value_color
  raise NotImplementedError
end

#value_textObject

Raises:

  • (NotImplementedError)

21
22
23
# File 'lib/gitlab/badge/template.rb', line 21

def value_text
  raise NotImplementedError
end

#value_text_anchorObject


45
46
47
# File 'lib/gitlab/badge/template.rb', line 45

def value_text_anchor
  key_width + (value_width / 2)
end

#value_widthObject

Raises:

  • (NotImplementedError)

29
30
31
# File 'lib/gitlab/badge/template.rb', line 29

def value_width
  raise NotImplementedError
end

#widthObject


49
50
51
# File 'lib/gitlab/badge/template.rb', line 49

def width
  key_width + value_width
end