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
-
.new(node) ⇒ NodeTarget
constructor
: (node node) -> void.
Instance Attribute Summary
- #node readonly
Instance Method Summary
-
#encloses?(comment) ⇒ Boolean
: (Comment comment) -> bool.
-
#end_offset
: () -> Integer.
-
#leading_comment(comment)
: (Comment comment) -> void.
-
#start_offset
: () -> Integer.
-
#trailing_comment(comment)
: (Comment comment) -> void.
Constructor Details
.new(node) ⇒ NodeTarget
: (node node) -> void
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
# 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
# File 'lib/prism/parse_result/comments.rb', line 50
def end_offset node.end_offset end
#leading_comment(comment)
: (Comment comment) -> void
# File 'lib/prism/parse_result/comments.rb', line 61
def leading_comment(comment) node.location.leading_comment(comment) end
#start_offset
: () -> Integer
# File 'lib/prism/parse_result/comments.rb', line 45
def start_offset node.start_offset end
#trailing_comment(comment)
: (Comment comment) -> void
# File 'lib/prism/parse_result/comments.rb', line 66
def trailing_comment(comment) node.location.trailing_comment(comment) end