class SyntaxTree::Comment

Comment represents a comment in the source.

# comment

Attributes

inline[R]
boolean

whether or not there is code on the same line as this comment.

If there is, then inline will be true.

inline?[R]
boolean

whether or not there is code on the same line as this comment.

If there is, then inline will be true.

value[R]
String

the contents of the comment

Public Class Methods

new(value:, inline:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 3734
def initialize(value:, inline:, location:)
  @value = value
  @inline = inline
  @location = location

  @leading = false
  @trailing = false
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 3793
def ===(other)
  other.is_a?(Comment) && value === other.value && inline === other.inline
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 3767
def accept(visitor)
  visitor.visit_comment(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 3771
def child_nodes
  []
end
Also aliased as: deconstruct
comments() click to toggle source
# File lib/syntax_tree/node.rb, line 3763
def comments
  []
end
copy(value: nil, inline: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 3775
def copy(value: nil, inline: nil, location: nil)
  Comment.new(
    value: value || self.value,
    inline: inline || self.inline,
    location: location || self.location
  )
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 3785
def deconstruct_keys(_keys)
  { value: value, inline: inline, location: location }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 3789
def format(q)
  q.text(value)
end
ignore?() click to toggle source
# File lib/syntax_tree/node.rb, line 3759
def ignore?
  value.match?(/\A#\s*stree-ignore\s*\z/)
end
leading!() click to toggle source
# File lib/syntax_tree/node.rb, line 3743
def leading!
  @leading = true
end
leading?() click to toggle source
# File lib/syntax_tree/node.rb, line 3747
def leading?
  @leading
end
trailing!() click to toggle source
# File lib/syntax_tree/node.rb, line 3751
def trailing!
  @trailing = true
end
trailing?() click to toggle source
# File lib/syntax_tree/node.rb, line 3755
def trailing?
  @trailing
end