Exception: Synthra::Errors::InvalidProbabilityError

Inherits:
ParseError
  • Object
show all
Defined in:
lib/synthra/errors.rb

Overview

Invalid probability specification

Raised when enum probabilities exceed 100% total.

Examples:

# status: enum(active:60%, inactive:60%)  <- total 120% > 100%

Constant Summary collapse

ERROR_CODE =
"INVALID_PROBABILITY_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total, **kwargs) ⇒ InvalidProbabilityError

Create a new InvalidProbabilityError

Parameters:

  • total (Numeric)

    the total probability percentage

  • kwargs (Hash)

    location information (line, column, source_line)



413
414
415
416
# File 'lib/synthra/errors.rb', line 413

def initialize(total, **kwargs)
  @total = total
  super("Probability total #{total}% exceeds 100%", **kwargs)
end

Instance Attribute Details

#totalNumeric (readonly)

Returns the total probability that exceeded 100%.

Returns:

  • (Numeric)

    the total probability that exceeded 100%



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/synthra/errors.rb', line 402

class InvalidProbabilityError < ParseError
  ERROR_CODE = "INVALID_PROBABILITY_ERROR"
  attr_reader :total


  # Create a new InvalidProbabilityError
  #
  # @param total [Numeric] the total probability percentage
  # @param kwargs [Hash] location information (line, column, source_line)
  #

  def initialize(total, **kwargs)
    @total = total
    super("Probability total #{total}% exceeds 100%", **kwargs)
  end
end