Class: SyntaxTree::Comment
Overview
Comment represents a comment in the source.
# comment
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
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #comments ⇒ Object
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
- #ignore? ⇒ Boolean
-
#initialize(value:, inline:, location:) ⇒ Comment
constructor
A new instance of Comment.
- #leading! ⇒ Object
- #leading? ⇒ Boolean
- #trailing! ⇒ Object
- #trailing? ⇒ Boolean
Methods inherited from Node
Constructor Details
#initialize(value:, inline:, location:) ⇒ Comment
Returns a new instance of Comment.
3055 3056 3057 3058 3059 3060 3061 3062 |
# File 'lib/syntax_tree/node.rb', line 3055 def initialize(value:, inline:, location:) @value = value @inline = inline @location = location @leading = false @trailing = false end |
Instance Attribute Details
#inline ⇒ Object (readonly) 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.
3052 3053 3054 |
# File 'lib/syntax_tree/node.rb', line 3052 def inline @inline end |
#value ⇒ Object (readonly)
- String
-
the contents of the comment
3048 3049 3050 |
# File 'lib/syntax_tree/node.rb', line 3048 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
3088 3089 3090 |
# File 'lib/syntax_tree/node.rb', line 3088 def accept(visitor) visitor.visit_comment(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3092 3093 3094 |
# File 'lib/syntax_tree/node.rb', line 3092 def child_nodes [] end |
#comments ⇒ Object
3084 3085 3086 |
# File 'lib/syntax_tree/node.rb', line 3084 def comments [] end |
#deconstruct_keys(keys) ⇒ Object
3098 3099 3100 |
# File 'lib/syntax_tree/node.rb', line 3098 def deconstruct_keys(keys) { value: value, inline: inline, location: location } end |
#format(q) ⇒ Object
3102 3103 3104 |
# File 'lib/syntax_tree/node.rb', line 3102 def format(q) q.text(value) end |
#ignore? ⇒ Boolean
3080 3081 3082 |
# File 'lib/syntax_tree/node.rb', line 3080 def ignore? value[1..-1].strip == "stree-ignore" end |
#leading! ⇒ Object
3064 3065 3066 |
# File 'lib/syntax_tree/node.rb', line 3064 def leading! @leading = true end |
#leading? ⇒ Boolean
3068 3069 3070 |
# File 'lib/syntax_tree/node.rb', line 3068 def leading? @leading end |
#trailing! ⇒ Object
3072 3073 3074 |
# File 'lib/syntax_tree/node.rb', line 3072 def trailing! @trailing = true end |
#trailing? ⇒ Boolean
3076 3077 3078 |
# File 'lib/syntax_tree/node.rb', line 3076 def trailing? @trailing end |