Exception: NRSER::CountError

Inherits:
AttrError show all
Defined in:
lib/nrser/errors/count_error.rb

Overview

Raised when we expected ‘#count` to be something it’s not.

Extends ValueError, and the #value must be the instance that

Instance Attribute Summary

Attributes inherited from AttrError

#actual, #expected, #symbol

Attributes inherited from ValueError

#subject

Instance Method Summary collapse

Methods inherited from AttrError

#build_message, #has_expected?

Methods inherited from ValueError

#build_message

Constructor Details

#initialize(message = nil, subject:, expected:, count: nil) ⇒ CountError

Returns a new instance of CountError.



8
9
10
11
12
13
14
# File 'lib/nrser/errors/count_error.rb', line 8

def initialize message = nil, subject:, expected:, count: nil
  super message,
    subject: subject,
    symbol: :count,
    actual: (count || subject.count),
    expected: expected
end

Instance Method Details

#countObject



16
17
18
# File 'lib/nrser/errors/count_error.rb', line 16

def count
  actual
end