class SyntaxTree::Label

Label represents the use of an identifier to associate with an object. You can find it in a hash key, as in:

{ key: value }

In this case “key:” would be the body of the label. You can also find it in pattern matching, as in:

case value
in key:
end

In this case “key:” would be the body of the label.

Attributes

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

value[R]
String

the value of the label

Public Class Methods

new(value:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 7059
def initialize(value:, location:)
  @value = value
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 7094
def ===(other)
  other.is_a?(Label) && value === other.value
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 7065
def accept(visitor)
  visitor.visit_label(self)
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 7069
def child_nodes
  []
end
Also aliased as: deconstruct
copy(value: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 7073
def copy(value: nil, location: nil)
  node =
    Label.new(
      value: value || self.value,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 7086
def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 7090
def format(q)
  q.text(value)
end