Class: IsEmail::Diagnosis::Base Private
- Inherits:
-
Object
- Object
- IsEmail::Diagnosis::Base
- Includes:
- Comparable
- Defined in:
- lib/is_email/diagnosis/base.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An abstract superclass for all diagnoses
Constant Summary collapse
- DESCRIPTION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
""- ERROR_CODES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{}.freeze
- MESSAGES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{}.freeze
- REFERENCES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{}.freeze
Instance Attribute Summary collapse
- #code ⇒ Integer readonly private
- #message ⇒ String readonly private
- #references ⇒ Array<Reference> readonly private
- #type ⇒ String readonly private
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
private
Allows sorting with Numerics and other diagnoses.
-
#==(other) ⇒ Boolean
(also: #eql?)
private
Part of the [value object semantics] to make diagnoses equalable.
-
#hash ⇒ Integer
private
Part of the [value object semantics] to make diagnoses equalable.
- #initialize(type) ⇒ void constructor private
- #inspect ⇒ String private
Constructor Details
#initialize(type) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 |
# File 'lib/is_email/diagnosis/base.rb', line 18 def initialize(type) @code = self.class::ERROR_CODES.fetch(type) @message = self.class::MESSAGES.fetch(type, "") @references = self.class::REFERENCES.fetch(type) { [] }.map { |ref| Reference.new(ref) } @type = type.to_s end |
Instance Attribute Details
#code ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/is_email/diagnosis/base.rb', line 26 def code @code end |
#message ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/is_email/diagnosis/base.rb', line 29 def @message end |
#references ⇒ Array<Reference> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/is_email/diagnosis/base.rb', line 32 def references @references end |
#type ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# File 'lib/is_email/diagnosis/base.rb', line 35 def type @type end |
Instance Method Details
#<=>(other) ⇒ -1, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allows sorting with Numerics and other diagnoses
52 53 54 55 56 57 58 59 |
# File 'lib/is_email/diagnosis/base.rb', line 52 def <=>(other) case other when Base code <=> other.code when Numeric code <=> other end end |
#==(other) ⇒ Boolean Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Part of the [value object semantics] to make diagnoses equalable
43 44 45 |
# File 'lib/is_email/diagnosis/base.rb', line 43 def ==(other) other.instance_of?(self.class) && (self <=> other).zero? end |
#hash ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Part of the [value object semantics] to make diagnoses equalable
66 67 68 |
# File 'lib/is_email/diagnosis/base.rb', line 66 def hash [self.class, type].hash end |
#inspect ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 |
# File 'lib/is_email/diagnosis/base.rb', line 71 def inspect "#<#{self.class.name}: #{type}>" end |