Class: BrandLogo::Config

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/brand_logo/config.rb

Overview

Immutable configuration object for the gem. Centralizes all runtime parameters, replacing the 4 primitive kwargs previously duplicated across every strategy constructor.

Usage:

config = BrandLogo::Config.new(min_dimensions: { width: 32, height: 32 }, timeout: 5)

Constant Summary collapse

DEFAULT_TIMEOUT =
T.let(10, Integer)
DEFAULT_MAX_HOPS =
T.let(5, Integer)
DEFAULT_MIN_DIMENSIONS =
T.let({ width: 0, height: 0 }.freeze, T::Hash[Symbol, Integer])
DEFAULT_DIMENSIONS =
T.let({ width: 16, height: 16 }.freeze, T::Hash[Symbol, Integer])
DEFAULT_FAVICON_PATH =
T.let('/favicon.ico', String)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(min_dimensions: DEFAULT_MIN_DIMENSIONS, max_dimensions: nil, allow_svg: true, timeout: DEFAULT_TIMEOUT, max_hops: DEFAULT_MAX_HOPS) ⇒ Config

Returns a new instance of Config.



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/brand_logo/config.rb', line 46

def initialize(
  min_dimensions: DEFAULT_MIN_DIMENSIONS,
  max_dimensions: nil,
  allow_svg: true,
  timeout: DEFAULT_TIMEOUT,
  max_hops: DEFAULT_MAX_HOPS
)
  @min_dimensions = T.let(min_dimensions, T::Hash[Symbol, Integer])
  @max_dimensions = T.let(max_dimensions, T.nilable(T::Hash[Symbol, Integer]))
  @allow_svg      = T.let(allow_svg, T::Boolean)
  @timeout        = T.let(timeout, Integer)
  @max_hops       = T.let(max_hops, Integer)
end

Instance Attribute Details

#allow_svgObject (readonly)

Returns the value of attribute allow_svg.



29
30
31
# File 'lib/brand_logo/config.rb', line 29

def allow_svg
  @allow_svg
end

#max_dimensionsObject (readonly)

Returns the value of attribute max_dimensions.



26
27
28
# File 'lib/brand_logo/config.rb', line 26

def max_dimensions
  @max_dimensions
end

#max_hopsObject (readonly)

Returns the value of attribute max_hops.



35
36
37
# File 'lib/brand_logo/config.rb', line 35

def max_hops
  @max_hops
end

#min_dimensionsObject (readonly)

Returns the value of attribute min_dimensions.



23
24
25
# File 'lib/brand_logo/config.rb', line 23

def min_dimensions
  @min_dimensions
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



32
33
34
# File 'lib/brand_logo/config.rb', line 32

def timeout
  @timeout
end