123456789_123456789_123456789_123456789_123456789_

Class: Prism::ParseWarning

Relationships & Source Files
Inherits: Object
Defined in: lib/prism/parse_result.rb,
prism/extension.c

Overview

This represents a warning that was encountered during parsing.

Class Method Summary

Instance Attribute Summary

  • #level readonly

    The level of this warning.

  • #location readonly

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

  • #message readonly

    The message associated with this warning.

  • #type readonly

    The type of warning.

Instance Method Summary

Constructor Details

.new(type, message, location, level) ⇒ ParseWarning

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

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 641

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

Instance Attribute Details

#level (readonly)

The level of this warning.

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 638

attr_reader :level

#location (readonly)

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

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 635

attr_reader :location

#message (readonly)

The message associated with this warning.

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 632

attr_reader :message

#type (readonly)

The type of warning. This is an internal symbol that is used for communicating with translation layers. It is not meant to be public API.

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 629

attr_reader :type

Instance Method Details

#deconstruct_keys(keys)

Implement the hash pattern matching interface for ParseWarning.

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 649

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

#inspect

Returns a string representation of this warning.

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 654

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