Class: Prism::ParseWarning

Inherits:
Object
  • Object
show all
Defined in:
lib/prism/parse_result.rb,
ext/prism/extension.c

Overview

This represents a warning that was encountered during parsing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, message, location, level) ⇒ ParseWarning

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



509
510
511
512
513
514
# File 'lib/prism/parse_result.rb', line 509

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

Instance Attribute Details

#levelObject (readonly)

The level of this warning.



506
507
508
# File 'lib/prism/parse_result.rb', line 506

def level
  @level
end

#locationObject (readonly)

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



503
504
505
# File 'lib/prism/parse_result.rb', line 503

def location
  @location
end

#messageObject (readonly)

The message associated with this warning.



500
501
502
# File 'lib/prism/parse_result.rb', line 500

def message
  @message
end

#typeObject (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.



497
498
499
# File 'lib/prism/parse_result.rb', line 497

def type
  @type
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object

Implement the hash pattern matching interface for ParseWarning.



517
518
519
# File 'lib/prism/parse_result.rb', line 517

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

#inspectObject

Returns a string representation of this warning.



522
523
524
# File 'lib/prism/parse_result.rb', line 522

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