Exception: Plurimath::Math::ParseOptionError

Inherits:
Error
  • Object
show all
Defined in:
lib/plurimath/errors/parse_option_error.rb

Class Method Summary collapse

Class Method Details

.be_verb(options) ⇒ Object



25
26
27
# File 'lib/plurimath/errors/parse_option_error.rb', line 25

def self.be_verb(options)
  options.one? ? "is" : "are"
end

.format_options(options) ⇒ Object



29
30
31
# File 'lib/plurimath/errors/parse_option_error.rb', line 29

def self.format_options(options)
  options.map(&:inspect).join(", ")
end

.option_label(options) ⇒ Object



21
22
23
# File 'lib/plurimath/errors/parse_option_error.rb', line 21

def self.option_label(options)
  options.one? ? "option" : "options"
end

.unknown_options(options, supported_options:) ⇒ Object



6
7
8
9
10
11
# File 'lib/plurimath/errors/parse_option_error.rb', line 6

def self.unknown_options(options, supported_options:)
  new(
    "unknown parse #{option_label(options)}: #{format_options(options)}; " \
    "supported parse options are #{format_options(supported_options)}",
  )
end

.unsupported_options(type, options, supported_types:) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/plurimath/errors/parse_option_error.rb', line 13

def self.unsupported_options(type, options, supported_types:)
  new(
    "parse #{option_label(options)} #{format_options(options)} " \
    "#{be_verb(options)} not supported for #{type.inspect}; " \
    "supported input types are #{format_options(supported_types)}",
  )
end