Class: Prism::Comment
- Inherits:
- 
      Object
      
        - Object
- Prism::Comment
 
- Defined in:
- lib/prism/parse_result.rb,
 ext/prism/extension.c
Overview
This represents a comment that was encountered during parsing.
Constant Summary collapse
- TYPES =
- [:inline, :embdoc, :__END__] 
Instance Attribute Summary collapse
- 
  
    
      #location  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute location. 
- 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute type. 
Instance Method Summary collapse
- #deconstruct_keys(keys) ⇒ Object
- 
  
    
      #initialize(type, location)  ⇒ Comment 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Comment. 
- #inspect ⇒ Object
- 
  
    
      #trailing?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Returns true if the comment happens on the same line as other code and false if the comment is by itself. 
Constructor Details
#initialize(type, location) ⇒ Comment
Returns a new instance of Comment.
| 150 151 152 153 | # File 'lib/prism/parse_result.rb', line 150 def initialize(type, location) @type = type @location = location end | 
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
| 148 149 150 | # File 'lib/prism/parse_result.rb', line 148 def location @location end | 
#type ⇒ Object (readonly)
Returns the value of attribute type.
| 148 149 150 | # File 'lib/prism/parse_result.rb', line 148 def type @type end | 
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
| 155 156 157 | # File 'lib/prism/parse_result.rb', line 155 def deconstruct_keys(keys) { type: type, location: location } end | 
#inspect ⇒ Object
| 164 165 166 | # File 'lib/prism/parse_result.rb', line 164 def inspect "#<Prism::Comment @type=#{@type.inspect} @location=#{@location.inspect}>" end | 
#trailing? ⇒ Boolean
Returns true if the comment happens on the same line as other code and false if the comment is by itself
| 160 161 162 | # File 'lib/prism/parse_result.rb', line 160 def trailing? type == :inline && !location.start_line_slice.strip.empty? end |