Exception: Plurimath::DeprecationError

Inherits:
Error
  • Object
show all
Defined in:
lib/plurimath/errors/deprecation_error.rb

Constant Summary collapse

SEVERITY =
:warning

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature:, message: nil, replacement: nil, since: nil, remove_in: nil) ⇒ DeprecationError

Returns a new instance of DeprecationError.



9
10
11
12
13
14
15
16
# File 'lib/plurimath/errors/deprecation_error.rb', line 9

def initialize(feature:, message: nil, replacement: nil, since: nil, remove_in: nil)
  @feature = feature
  @replacement = replacement
  @since = since
  @remove_in = remove_in
  @user_message = message
  super(to_s)
end

Instance Attribute Details

#featureObject (readonly)

Returns the value of attribute feature.



7
8
9
# File 'lib/plurimath/errors/deprecation_error.rb', line 7

def feature
  @feature
end

#remove_inObject (readonly)

Returns the value of attribute remove_in.



7
8
9
# File 'lib/plurimath/errors/deprecation_error.rb', line 7

def remove_in
  @remove_in
end

#replacementObject (readonly)

Returns the value of attribute replacement.



7
8
9
# File 'lib/plurimath/errors/deprecation_error.rb', line 7

def replacement
  @replacement
end

#sinceObject (readonly)

Returns the value of attribute since.



7
8
9
# File 'lib/plurimath/errors/deprecation_error.rb', line 7

def since
  @since
end

Instance Method Details

#severityObject



18
19
20
# File 'lib/plurimath/errors/deprecation_error.rb', line 18

def severity
  SEVERITY
end

#to_sObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/plurimath/errors/deprecation_error.rb', line 22

def to_s
  deprecation = "[plurimath][DEPRECATION] #{feature} is deprecated"
  deprecation = "#{deprecation} since #{since}" if since
  deprecation = "#{deprecation} and will be removed in #{remove_in}" if remove_in

  parts = [deprecation]
  parts << "Use #{replacement} instead" if replacement
  parts << @user_message if @user_message
  "#{parts.join('. ')}."
end