123456789_123456789_123456789_123456789_123456789_

Class: Prism::ParseResult::Comments::NodeTarget

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/prism/parse_result/comments.rb

Overview

A target for attaching comments that is based on a specific node’s location.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(node) ⇒ NodeTarget

[ GitHub ]

  
# File 'lib/prism/parse_result/comments.rb', line 25

def initialize(node)
  @node = node
end

Instance Attribute Details

#node (readonly)

[ GitHub ]

  
# File 'lib/prism/parse_result/comments.rb', line 23

attr_reader :node

Instance Method Details

#<<(comment)

[ GitHub ]

  
# File 'lib/prism/parse_result/comments.rb', line 42

def <<(comment)
  node.location.comments << comment
end

#encloses?(comment) ⇒ Boolean

[ GitHub ]

  
# File 'lib/prism/parse_result/comments.rb', line 37

def encloses?(comment)
  start_offset <= comment.location.start_offset &&
    comment.location.end_offset <= end_offset
end

#end_offset

[ GitHub ]

  
# File 'lib/prism/parse_result/comments.rb', line 33

def end_offset
  node.location.end_offset
end

#start_offset

[ GitHub ]

  
# File 'lib/prism/parse_result/comments.rb', line 29

def start_offset
  node.location.start_offset
end