Exception: MiniRuby::Compiler::Error

Inherits:
Error
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/miniruby/compiler.rb

Overview

Wraps a list of compiler errors.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ Error

: (Array errors) -> void



30
31
32
33
# File 'lib/miniruby/compiler.rb', line 30

def initialize(errors)
  @errors = errors
  super(@errors.join('; '))
end

Instance Attribute Details

#errorsObject (readonly)

: Array



27
28
29
# File 'lib/miniruby/compiler.rb', line 27

def errors
  @errors
end

Class Method Details

.[](*errors) ⇒ Object

: (*String errors) -> instance



21
22
23
# File 'lib/miniruby/compiler.rb', line 21

def [](*errors)
  new(errors)
end

Instance Method Details

#==(other) ⇒ Object

: (Object other) -> bool



36
37
38
39
40
# File 'lib/miniruby/compiler.rb', line 36

def ==(other)
  return false unless other.is_a?(Error)

  @errors == other.errors
end

#inspectObject

: -> String



43
44
45
# File 'lib/miniruby/compiler.rb', line 43

def inspect
  "#{self.class}#{@errors.inspect}"
end