Class: SyntaxTree::Comment
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Comment
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Comment represents a comment in the source.
Instance Attribute Summary collapse
-
#inline ⇒ Object
(also: #inline?)
readonly
- boolean
-
whether or not there is code on the same line as this comment.
-
#value ⇒ Object
readonly
- String
-
the contents of the comment.
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, inline:, location:) ⇒ Comment
Returns a new instance of Comment.
3253
3254
3255
3256
3257
3258
3259
3260
|
# File 'lib/syntax_tree/node.rb', line 3253
def initialize(value:, inline:, location:)
@value = value
@inline = inline
@location = location
@leading = false
@trailing = false
end
|
Instance Attribute Details
#inline ⇒ Object
Also known as:
inline?
- boolean
-
whether or not there is code on the same line as this comment.
If there is, then inline will be true.
3250
3251
3252
|
# File 'lib/syntax_tree/node.rb', line 3250
def inline
@inline
end
|
#value ⇒ Object
- String
-
the contents of the comment
3246
3247
3248
|
# File 'lib/syntax_tree/node.rb', line 3246
def value
@value
end
|
Instance Method Details
#accept(visitor) ⇒ Object
3286
3287
3288
|
# File 'lib/syntax_tree/node.rb', line 3286
def accept(visitor)
visitor.(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3290
3291
3292
|
# File 'lib/syntax_tree/node.rb', line 3290
def child_nodes
[]
end
|
3282
3283
3284
|
# File 'lib/syntax_tree/node.rb', line 3282
def
[]
end
|
#deconstruct_keys(_keys) ⇒ Object
3296
3297
3298
|
# File 'lib/syntax_tree/node.rb', line 3296
def deconstruct_keys(_keys)
{ value: value, inline: inline, location: location }
end
|
3300
3301
3302
|
# File 'lib/syntax_tree/node.rb', line 3300
def format(q)
q.text(value)
end
|
#ignore? ⇒ Boolean
3278
3279
3280
|
# File 'lib/syntax_tree/node.rb', line 3278
def ignore?
value.match?(/\A#\s*stree-ignore\s*\z/)
end
|
#leading! ⇒ Object
3262
3263
3264
|
# File 'lib/syntax_tree/node.rb', line 3262
def leading!
@leading = true
end
|
#leading? ⇒ Boolean
3266
3267
3268
|
# File 'lib/syntax_tree/node.rb', line 3266
def leading?
@leading
end
|
#trailing! ⇒ Object
3270
3271
3272
|
# File 'lib/syntax_tree/node.rb', line 3270
def trailing!
@trailing = true
end
|
#trailing? ⇒ Boolean
3274
3275
3276
|
# File 'lib/syntax_tree/node.rb', line 3274
def trailing?
@trailing
end
|