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.
26 27 28 |
# File 'lib/prism/parse_result/comments.rb', line 26 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
:nodoc:
24 25 26 |
# File 'lib/prism/parse_result/comments.rb', line 24 def node @node end |
Instance Method Details
#encloses?(comment) ⇒ Boolean
38 39 40 41 |
# File 'lib/prism/parse_result/comments.rb', line 38 def encloses?(comment) start_offset <= comment.location.start_offset && comment.location.end_offset <= end_offset end |
#end_offset ⇒ Object
34 35 36 |
# File 'lib/prism/parse_result/comments.rb', line 34 def end_offset node.end_offset end |
#leading_comment(comment) ⇒ Object
43 44 45 |
# File 'lib/prism/parse_result/comments.rb', line 43 def leading_comment(comment) node.location.leading_comment(comment) end |
#start_offset ⇒ Object
30 31 32 |
# File 'lib/prism/parse_result/comments.rb', line 30 def start_offset node.start_offset end |
#trailing_comment(comment) ⇒ Object
47 48 49 |
# File 'lib/prism/parse_result/comments.rb', line 47 def trailing_comment(comment) node.location.trailing_comment(comment) end |