Class: Prism::ParseWarning

Inherits:
Object show all
Defined in:
lib/prism/parse_result.rb

Overview

This represents a warning that was encountered during parsing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, location, level) ⇒ ParseWarning

Create a new warning object with the given message and location.



348
349
350
351
352
# File 'lib/prism/parse_result.rb', line 348

def initialize(message, location, level)
  @message = message
  @location = location
  @level = level
end

Instance Attribute Details

#levelObject (readonly)

The level of this warning.



345
346
347
# File 'lib/prism/parse_result.rb', line 345

def level
  @level
end

#locationObject (readonly)

A Location object representing the location of this warning in the source.



342
343
344
# File 'lib/prism/parse_result.rb', line 342

def location
  @location
end

#messageObject (readonly)

The message associated with this warning.



339
340
341
# File 'lib/prism/parse_result.rb', line 339

def message
  @message
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object

Implement the hash pattern matching interface for ParseWarning.



355
356
357
# File 'lib/prism/parse_result.rb', line 355

def deconstruct_keys(keys)
  { message: message, location: location, level: level }
end

#inspectObject

Returns a string representation of this warning.



360
361
362
# File 'lib/prism/parse_result.rb', line 360

def inspect
  "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>"
end