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.
2707 2708 2709 2710 2711 2712 2713 2714 |
# File 'lib/syntax_tree/node.rb', line 2707 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.
2704 2705 2706 |
# File 'lib/syntax_tree/node.rb', line 2704 def inline @inline end |
#value ⇒ Object (readonly)
- String
-
the contents of the comment
2700 2701 2702 |
# File 'lib/syntax_tree/node.rb', line 2700 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
2740 2741 2742 |
# File 'lib/syntax_tree/node.rb', line 2740 def accept(visitor) visitor.visit_comment(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2744 2745 2746 |
# File 'lib/syntax_tree/node.rb', line 2744 def child_nodes [] end |
#comments ⇒ Object
2736 2737 2738 |
# File 'lib/syntax_tree/node.rb', line 2736 def comments [] end |
#deconstruct_keys(keys) ⇒ Object
2750 2751 2752 |
# File 'lib/syntax_tree/node.rb', line 2750 def deconstruct_keys(keys) { value: value, inline: inline, location: location } end |
#format(q) ⇒ Object
2754 2755 2756 |
# File 'lib/syntax_tree/node.rb', line 2754 def format(q) q.text(value) end |
#ignore? ⇒ Boolean
2732 2733 2734 |
# File 'lib/syntax_tree/node.rb', line 2732 def ignore? value[1..-1].strip == "stree-ignore" end |
#leading! ⇒ Object
2716 2717 2718 |
# File 'lib/syntax_tree/node.rb', line 2716 def leading! @leading = true end |
#leading? ⇒ Boolean
2720 2721 2722 |
# File 'lib/syntax_tree/node.rb', line 2720 def leading? @leading end |
#trailing! ⇒ Object
2724 2725 2726 |
# File 'lib/syntax_tree/node.rb', line 2724 def trailing! @trailing = true end |
#trailing? ⇒ Boolean
2728 2729 2730 |
# File 'lib/syntax_tree/node.rb', line 2728 def trailing? @trailing end |