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.

Constant Summary

Constants included from NicerError

NicerError::DEFAULT_COLUMN_WIDTH

Instance Method Summary collapse

Methods inherited from AttrError

#actual, #actual?, #default_message, #expected, #expected?, #name, #name?

Methods inherited from ValueError

#value, #value?

Methods included from NicerError

#add_extended_message?, column_width, #context, #context_section, #default_message, #details, #details_section, #extended_message, #format_message, #format_message_segment, included, #to_s

Constructor Details

#initialize(*message, **kwds) ⇒ CountError

Create a new NRSER::CountError.

Parameters:

Options Hash (**kwds):

  • :value (Object)

    The value that has the bad ‘#count`.

  • :expected (Integer | NRSER::Types::Type | String)

    Encouraged to be one of:

    1. An exact Integer that you were looking for.

    2. A Types::Type satisfied by what you would have been satisfied with.

    3. A String explanation of the condition.

  • :actual (Integer)

    The actual count.



51
52
53
54
# File 'lib/nrser/errors/count_error.rb', line 51

def initialize *message, **kwds
  kwds[:actual] = kwds.delete( :count ) if kwds.key?( :count )
  super *message, **kwds, name: :count
end

Instance Method Details

#countObject

Alias for AttrError#actual.



60
# File 'lib/nrser/errors/count_error.rb', line 60

def count; actual; end

#count?Boolean

Alias for AttrError#actual?.

Returns:

  • (Boolean)


57
# File 'lib/nrser/errors/count_error.rb', line 57

def count?; actual?; end