Class: RepoSmallBadge::Image
- Inherits:
-
Object
- Object
- RepoSmallBadge::Image
- Defined in:
- lib/repo_small_badge/image.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#badge(name, title, value, state) ⇒ Object
Creates the badge.
-
#initialize(config = {}) ⇒ Image
constructor
Create new instance.
Constructor Details
#initialize(config = {}) ⇒ Image
Create new instance.
12 13 14 15 16 17 18 19 20 |
# File 'lib/repo_small_badge/image.rb', line 12 def initialize(config = {}) raise ImageMagicError, 'Imagemagick is not installed on this system.' \ unless MiniMagick.imagemagick? @config = config MiniMagick.logger = Logger.new($stdout, level: @config.fetch(:log_level, 'info') .to_sym) end |
Instance Method Details
#badge(name, title, value, state) ⇒ Object
Creates the badge.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/repo_small_badge/image.rb', line 28 def badge(name, title, value, state) MiniMagick::Tool::Convert.new do |convert| convert.gravity('center') convert.background(@config.fetch(:background, 'transparent')) convert.pango(pango(title, value, state)) rounded_border? && rounded_border(convert, @config.fetch(:rounded_edge_radius, 3)) convert << filename(name) end true end |