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

: (node node) -> void

[ GitHub ]

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

def initialize(node)
  @node = node
end

Instance Attribute Details

#node (readonly)

[ GitHub ]

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

attr_reader :node #: node

Instance Method Details

#encloses?(comment) ⇒ Boolean

: (Comment comment) -> bool

[ GitHub ]

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

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

#end_offset

: () -> Integer

[ GitHub ]

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

def end_offset
  node.end_offset
end

#leading_comment(comment)

: (Comment comment) -> void

[ GitHub ]

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

def leading_comment(comment)
  node.location.leading_comment(comment)
end

#start_offset

: () -> Integer

[ GitHub ]

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

def start_offset
  node.start_offset
end

#trailing_comment(comment)

: (Comment comment) -> void

[ GitHub ]

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

def trailing_comment(comment)
  node.location.trailing_comment(comment)
end