Exception: Plurimath::Math::InvalidTypeError

Inherits:
TypeError
  • Object
show all
Defined in:
lib/plurimath/errors/invalid_type_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(type = nil) ⇒ InvalidTypeError

Returns a new instance of InvalidTypeError.



6
7
8
# File 'lib/plurimath/errors/invalid_type_error.rb', line 6

def initialize(type = nil)
  super(type ? formula_message(type) : parse_message)
end

Instance Method Details

#formula_message(type) ⇒ Object



14
15
16
# File 'lib/plurimath/errors/invalid_type_error.rb', line 14

def formula_message(type)
  "Invalid type provided: #{type}. Must be one of #{Formula::MATH_ZONE_TYPES.join(', ')}."
end

#parse_messageObject



10
11
12
# File 'lib/plurimath/errors/invalid_type_error.rb', line 10

def parse_message
  "`type` must be one of: `#{Math::VALID_TYPES.keys.join('`, `')}`"
end