Class: Prism::MagicComment
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/prism/parse_result.rb | 
Overview
This represents a magic comment that was encountered during parsing.
Class Method Summary
- 
    
      .new(key_loc, value_loc)  ⇒ MagicComment 
    
    constructor
    
Create a new magic comment object with the given key and value locations.
 
Instance Attribute Summary
- 
    
      #key_loc  
    
    readonly
    
A Location object representing the location of the key in the source.
 - 
    
      #value_loc  
    
    readonly
    
A Location object representing the location of the value in the source.
 
Instance Method Summary
- 
    
      #deconstruct_keys(keys)  
    
    
Implement the hash pattern matching interface for
MagicComment. - 
    
      #inspect  
    
    
Returns a string representation of this magic comment.
 - 
    
      #key  
    
    
Returns the key of the magic comment by slicing it from the source code.
 - 
    
      #value  
    
    
Returns the value of the magic comment by slicing it from the source code.
 
Constructor Details
    .new(key_loc, value_loc)  ⇒ MagicComment 
  
Create a new magic comment object with the given key and value locations.
Instance Attribute Details
#key_loc (readonly)
A Location object representing the location of the key in the source.
# File 'lib/prism/parse_result.rb', line 577
attr_reader :key_loc
#value_loc (readonly)
A Location object representing the location of the value in the source.
# File 'lib/prism/parse_result.rb', line 580
attr_reader :value_loc
Instance Method Details
#deconstruct_keys(keys)
Implement the hash pattern matching interface for MagicComment.
#inspect
Returns a string representation of this magic comment.
#key
Returns the key of the magic comment by slicing it from the source code.
# File 'lib/prism/parse_result.rb', line 589
def key key_loc.slice end
#value
Returns the value of the magic comment by slicing it from the source code.
# File 'lib/prism/parse_result.rb', line 594
def value value_loc.slice end