Class: Gitlab::Ci::Badge::Metadata

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

Overview

Abstract class for badge 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.


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

def initialize(badge)
  @badge = badge
end

Instance Method Details

#image_urlObject

Raises:

  • (NotImplementedError)

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

def image_url
  raise NotImplementedError
end

Raises:

  • (NotImplementedError)

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

def link_url
  raise NotImplementedError
end

#titleObject

Raises:

  • (NotImplementedError)

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

def title
  raise NotImplementedError
end

#to_asciidocObject


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

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

#to_htmlObject


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

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

#to_markdownObject


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

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