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.
3056 3057 3058 3059 3060 3061 3062 3063 |
# File 'lib/syntax_tree/node.rb', line 3056 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.
3053 3054 3055 |
# File 'lib/syntax_tree/node.rb', line 3053 def inline @inline end |
#value ⇒ Object (readonly)
- String
-
the contents of the comment
3049 3050 3051 |
# File 'lib/syntax_tree/node.rb', line 3049 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
3089 3090 3091 |
# File 'lib/syntax_tree/node.rb', line 3089 def accept(visitor) visitor.visit_comment(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
3093 3094 3095 |
# File 'lib/syntax_tree/node.rb', line 3093 def child_nodes [] end |
#comments ⇒ Object
3085 3086 3087 |
# File 'lib/syntax_tree/node.rb', line 3085 def comments [] end |
#deconstruct_keys(keys) ⇒ Object
3099 3100 3101 |
# File 'lib/syntax_tree/node.rb', line 3099 def deconstruct_keys(keys) { value: value, inline: inline, location: location } end |
#format(q) ⇒ Object
3103 3104 3105 |
# File 'lib/syntax_tree/node.rb', line 3103 def format(q) q.text(value) end |
#ignore? ⇒ Boolean
3081 3082 3083 |
# File 'lib/syntax_tree/node.rb', line 3081 def ignore? value[1..-1].strip == "stree-ignore" end |
#leading! ⇒ Object
3065 3066 3067 |
# File 'lib/syntax_tree/node.rb', line 3065 def leading! @leading = true end |
#leading? ⇒ Boolean
3069 3070 3071 |
# File 'lib/syntax_tree/node.rb', line 3069 def leading? @leading end |
#trailing! ⇒ Object
3073 3074 3075 |
# File 'lib/syntax_tree/node.rb', line 3073 def trailing! @trailing = true end |
#trailing? ⇒ Boolean
3077 3078 3079 |
# File 'lib/syntax_tree/node.rb', line 3077 def trailing? @trailing end |