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.
3088
3089
3090
3091
3092
3093
3094
3095
|
# File 'lib/syntax_tree/node.rb', line 3088
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.
3085
3086
3087
|
# File 'lib/syntax_tree/node.rb', line 3085
def inline
@inline
end
|
#value ⇒ Object
- String
-
the contents of the comment
3081
3082
3083
|
# File 'lib/syntax_tree/node.rb', line 3081
def value
@value
end
|
Instance Method Details
#accept(visitor) ⇒ Object
3121
3122
3123
|
# File 'lib/syntax_tree/node.rb', line 3121
def accept(visitor)
visitor.(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3125
3126
3127
|
# File 'lib/syntax_tree/node.rb', line 3125
def child_nodes
[]
end
|
3117
3118
3119
|
# File 'lib/syntax_tree/node.rb', line 3117
def
[]
end
|
#deconstruct_keys(_keys) ⇒ Object
3131
3132
3133
|
# File 'lib/syntax_tree/node.rb', line 3131
def deconstruct_keys(_keys)
{ value: value, inline: inline, location: location }
end
|
3135
3136
3137
|
# File 'lib/syntax_tree/node.rb', line 3135
def format(q)
q.text(value)
end
|
#ignore? ⇒ Boolean
3113
3114
3115
|
# File 'lib/syntax_tree/node.rb', line 3113
def ignore?
value[1..].strip == "stree-ignore"
end
|
#leading! ⇒ Object
3097
3098
3099
|
# File 'lib/syntax_tree/node.rb', line 3097
def leading!
@leading = true
end
|
#leading? ⇒ Boolean
3101
3102
3103
|
# File 'lib/syntax_tree/node.rb', line 3101
def leading?
@leading
end
|
#trailing! ⇒ Object
3105
3106
3107
|
# File 'lib/syntax_tree/node.rb', line 3105
def trailing!
@trailing = true
end
|
#trailing? ⇒ Boolean
3109
3110
3111
|
# File 'lib/syntax_tree/node.rb', line 3109
def trailing?
@trailing
end
|