Class: RepoSmallBadge::Image

Inherits:
Victor::SVGBase
  • Object
show all
Defined in:
lib/repo_small_badge/image.rb

Overview

Class that creates the Badge SVG image. Behaviour is defined by the configuration hash. For the different configurables see RepoSmallBadge::Configuration.

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Image

Create new instance.



13
14
15
16
17
18
19
# File 'lib/repo_small_badge/image.rb', line 13

def initialize(config = {})
  @config = Configuration.new(config)
  super(template: :html, contentScriptType: 'text/ecmascript',
        contentStyleType: 'text/css', preserveAspectRatio: 'xMidYMid meet',
        version: '1.0',
        height: @config.badge_height, width: @config.badge_width)
end

Instance Method Details

#badge(name, title, value) ⇒ Object

Creates the badge.



25
26
27
28
29
30
31
32
# File 'lib/repo_small_badge/image.rb', line 25

def badge(name, title, value)
  svg_header
  svg_rounded_box
  svg_boxes
  svg_title(title)
  svg_value(value)
  save(@config.filename(name))
end

#config_merge(config) ⇒ Object

Updates the configuration settings and overwrites existing ones.



36
37
38
# File 'lib/repo_small_badge/image.rb', line 36

def config_merge(config)
  @config.merge!(config)
end