Class: Prism::ParseResult::Comments::NodeTarget
- Inherits:
-
Object
- Object
- Prism::ParseResult::Comments::NodeTarget
- Defined in:
- lib/prism/parse_result/comments.rb
Overview
A target for attaching comments that is based on a specific node’s location.
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #encloses?(comment) ⇒ Boolean
- #end_offset ⇒ Object
-
#initialize(node) ⇒ NodeTarget
constructor
A new instance of NodeTarget.
- #leading_comment(comment) ⇒ Object
- #start_offset ⇒ Object
- #trailing_comment(comment) ⇒ Object
Constructor Details
#initialize(node) ⇒ NodeTarget
Returns a new instance of NodeTarget.
25 26 27 |
# File 'lib/prism/parse_result/comments.rb', line 25 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
:nodoc:
23 24 25 |
# File 'lib/prism/parse_result/comments.rb', line 23 def node @node end |
Instance Method Details
#encloses?(comment) ⇒ Boolean
37 38 39 40 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/prism/parse_result/comments.rb', line 33 def end_offset node.end_offset end |
#leading_comment(comment) ⇒ Object
42 43 44 |
# File 'lib/prism/parse_result/comments.rb', line 42 def leading_comment(comment) node.location.leading_comment(comment) end |
#start_offset ⇒ Object
29 30 31 |
# File 'lib/prism/parse_result/comments.rb', line 29 def start_offset node.start_offset end |
#trailing_comment(comment) ⇒ Object
46 47 48 |
# File 'lib/prism/parse_result/comments.rb', line 46 def trailing_comment(comment) node.location.trailing_comment(comment) end |