123456789_123456789_123456789_123456789_123456789_

Class: Prism::ParseWarning

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

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 500

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 497

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 494

attr_reader :location

#message (readonly)

The message associated with this warning.

[ GitHub ]

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

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 488

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 508

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 513

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