Class: Spoom::Sorbet::Errors::Error

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/spoom/sorbet/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, line, message, code, more = []) ⇒ Error

: (String? file, Integer? line, String? message, Integer? code, ?Array more) -> void



138
139
140
141
142
143
144
145
# File 'lib/spoom/sorbet/errors.rb', line 138

def initialize(file, line, message, code, more = [])
  @file = file
  @line = line
  @message = message
  @code = code
  @more = more
  @files_from_error_sections = T.let(Set.new, T::Set[String])
end

Instance Attribute Details

#codeObject (readonly)

: Integer?



128
129
130
# File 'lib/spoom/sorbet/errors.rb', line 128

def code
  @code
end

#fileObject (readonly)

: String?



125
126
127
# File 'lib/spoom/sorbet/errors.rb', line 125

def file
  @file
end

#files_from_error_sectionsObject (readonly)

Other files associated with the error : Set



135
136
137
# File 'lib/spoom/sorbet/errors.rb', line 135

def files_from_error_sections
  @files_from_error_sections
end

#lineObject (readonly)

: Integer?



128
129
130
# File 'lib/spoom/sorbet/errors.rb', line 128

def line
  @line
end

#messageObject (readonly)

: String?



125
126
127
# File 'lib/spoom/sorbet/errors.rb', line 125

def message
  @message
end

#moreObject (readonly)

: Array



131
132
133
# File 'lib/spoom/sorbet/errors.rb', line 131

def more
  @more
end

Instance Method Details

#<=>(other) ⇒ Object

By default errors are sorted by location : (untyped other) -> Integer



149
150
151
152
153
# File 'lib/spoom/sorbet/errors.rb', line 149

def <=>(other)
  return 0 unless other.is_a?(Error)

  [file, line, code, message] <=> [other.file, other.line, other.code, other.message]
end

#to_sObject

: -> String



156
157
158
# File 'lib/spoom/sorbet/errors.rb', line 156

def to_s
  "#{file}:#{line}: #{message} (#{code})"
end