Class: Gitlab::Badge::Metadata

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::AssetTagHelper, ActionView::Helpers::UrlHelper, Routing
Defined in:
lib/gitlab/badge/metadata.rb

Overview

Abstract class for badge metadata

Direct Known Subclasses

Coverage::Metadata, Pipeline::Metadata

Instance Method Summary collapse

Methods included from Routing

add_helpers, includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

#initialize(badge) ⇒ Metadata

Returns a new instance of Metadata.


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

def initialize(badge)
  @badge = badge
end

Instance Method Details

#image_urlObject

Raises:

  • (NotImplementedError)

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

def image_url
  raise NotImplementedError
end

Raises:

  • (NotImplementedError)

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

def link_url
  raise NotImplementedError
end

#titleObject

Raises:

  • (NotImplementedError)

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

def title
  raise NotImplementedError
end

#to_asciidocObject


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

def to_asciidoc
  "image:#{image_url}[link=\"#{link_url}\",title=\"#{title}\"]"
end

#to_htmlObject


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

def to_html
  link_to(image_tag(image_url, alt: title), link_url)
end

#to_markdownObject


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

def to_markdown
  "[![#{title}](#{image_url})](#{link_url})"
end