Class: Shields::Badge::Base
- Inherits:
-
Object
- Object
- Shields::Badge::Base
- Defined in:
- lib/shields/badge/base.rb
Direct Known Subclasses
Activity::GithubCommitsSinceLatestRelease, Shields::Badge::Build::GithubBranchCheckRuns, CodeCoverage::Coveralls, Downloads::GemDownloadRank, Downloads::GemTotalDownloads, Social::GithubRepoStars
Constant Summary collapse
- HTTP_METHOD =
:get
- BASE_URL =
{ "svg" => "https://img.shields.io", "png" => "https://raster.shields.io", }
Instance Attribute Summary collapse
-
#anchor_href ⇒ Object
Returns the value of attribute anchor_href.
-
#anchor_params ⇒ Object
Returns the value of attribute anchor_params.
-
#image_type ⇒ Object
Returns the value of attribute image_type.
-
#label ⇒ Object
Returns the value of attribute label.
-
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
-
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
Class Method Summary collapse
Instance Method Summary collapse
-
#format(formatter) ⇒ Object
-
#initialize(path_parameters: {}, query_parameters: {}, image_type: "svg", **options) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(path_parameters: {}, query_parameters: {}, image_type: "svg", **options) ⇒ Base
Returns a new instance of Base.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/shields/badge/base.rb', line 33 def initialize(path_parameters: {}, query_parameters: {}, image_type: "svg", **) if path_parameters.nil? || path_parameters.empty? path_parameters = (, self.class::PathDto) end if query_parameters.nil? || query_parameters.empty? query_parameters = (, self.class::QueryDto) end self.path_parameters = self.class::PathDto.new(**path_parameters) self.query_parameters = self.class::QueryDto.new(**query_parameters) self.image_type = image_type self.anchor_href = .fetch(:anchor_href, nil) self.anchor_params = .fetch(:anchor_params, {}) self.label = .fetch(:label, nil) end |
Instance Attribute Details
#anchor_href ⇒ Object
Returns the value of attribute anchor_href.
26 27 28 |
# File 'lib/shields/badge/base.rb', line 26 def anchor_href @anchor_href end |
#anchor_params ⇒ Object
Returns the value of attribute anchor_params.
26 27 28 |
# File 'lib/shields/badge/base.rb', line 26 def anchor_params @anchor_params end |
#image_type ⇒ Object
Returns the value of attribute image_type.
26 27 28 |
# File 'lib/shields/badge/base.rb', line 26 def image_type @image_type end |
#label ⇒ Object
Returns the value of attribute label.
26 27 28 |
# File 'lib/shields/badge/base.rb', line 26 def label @label end |
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
26 27 28 |
# File 'lib/shields/badge/base.rb', line 26 def path_parameters @path_parameters end |
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
26 27 28 |
# File 'lib/shields/badge/base.rb', line 26 def query_parameters @query_parameters end |
Class Method Details
.anchor_href_url ⇒ Object
21 22 23 |
# File 'lib/shields/badge/base.rb', line 21 def anchor_href_url raise Errors::NotImplemented, "Subclasses must implement #anchor_href_url" end |
.img_src_url ⇒ Object
17 18 19 |
# File 'lib/shields/badge/base.rb', line 17 def img_src_url raise Errors::NotImplemented, "Subclasses must implement #img_src_url" end |
.label_text ⇒ Object
13 14 15 |
# File 'lib/shields/badge/base.rb', line 13 def label_text raise Errors::NotImplemented, "Subclasses must implement #label_text" end |
Instance Method Details
#format(formatter) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/shields/badge/base.rb', line 48 def format(formatter) args = formatter.signature.each_with_object({}) { |key, memo| memo[key] = send(key) } formatter.call( **args, ) end |