Class: SyntaxTree::RegexpEnd

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

RegexpEnd represents the end of a regular expression literal.

/.+/m

In the example above, the RegexpEnd event represents the /m at the end of the regular expression literal. You can also declare regular expression literals using %r, as in:

%r{.+}m

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(value:, location:) ⇒ RegexpEnd

Returns a new instance of RegexpEnd.



9148
9149
9150
9151
# File 'lib/syntax_tree/node.rb', line 9148

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#valueObject (readonly)

String

the end of the regular expression



9146
9147
9148
# File 'lib/syntax_tree/node.rb', line 9146

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



9174
9175
9176
# File 'lib/syntax_tree/node.rb', line 9174

def ===(other)
  other.is_a?(RegexpEnd) && value === other.value
end

#accept(visitor) ⇒ Object



9153
9154
9155
# File 'lib/syntax_tree/node.rb', line 9153

def accept(visitor)
  visitor.visit_regexp_end(self)
end

#child_nodesObject Also known as: deconstruct



9157
9158
9159
# File 'lib/syntax_tree/node.rb', line 9157

def child_nodes
  []
end

#copy(value: nil, location: nil) ⇒ Object



9161
9162
9163
9164
9165
9166
# File 'lib/syntax_tree/node.rb', line 9161

def copy(value: nil, location: nil)
  RegexpEnd.new(
    value: value || self.value,
    location: location || self.location
  )
end

#deconstruct_keys(_keys) ⇒ Object



9170
9171
9172
# File 'lib/syntax_tree/node.rb', line 9170

def deconstruct_keys(_keys)
  { value: value, location: location }
end