Class: LogoSoup::Style
- Inherits:
-
Object
- Object
- LogoSoup::Style
- Defined in:
- lib/logosoup/style.rb
Overview
Composes the core logic into a single style string.
Constant Summary collapse
- DEFAULTS =
{ scale_factor: 0.5, density_aware: true, density_factor: 0.5, contrast_threshold: 10, align_by: "visual-center-y", pixel_budget: 2_048 }.freeze
Class Method Summary collapse
-
.call(base_size:, svg: nil, image_path: nil, image_bytes: nil, content_type: nil, on_error: nil, **options) ⇒ String
Inline CSS style.
Class Method Details
.call(base_size:, svg: nil, image_path: nil, image_bytes: nil, content_type: nil, on_error: nil, **options) ⇒ String
Returns inline CSS style.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/logosoup/style.rb', line 22 def self.call(base_size:, svg: nil, image_path: nil, image_bytes: nil, content_type: nil, on_error: nil, **) opts = DEFAULTS.merge().merge(base_size: base_size) if svg handle_svg(svg, opts: opts, on_error: on_error) elsif image_path handle_image_path(image_path, opts: opts, on_error: on_error) elsif image_bytes handle_image_bytes(image_bytes, content_type: content_type, opts: opts, on_error: on_error) else fallback_style(opts) end rescue StandardError => e handle_error(e, opts: opts, on_error: on_error) end |