RegexpLiteral
represents a regular expression literal.
/.+/Attributes
the beginning of the regular expression literal
the ending of the regular expression literal
def initialize(beginning:, ending:, parts:, location:) @beginning = beginning @ending = ending @parts = parts @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(RegexpLiteral) && beginning === other.beginning && ending === other.ending && options === other.options && ArrayMatch.call(parts, other.parts) endSource
def accept(visitor) visitor.visit_regexp_literal(self) endSource
def child_nodes parts endSource
def copy(beginning: nil, ending: nil, parts: nil, location: nil) node = RegexpLiteral.new( beginning: beginning || self.beginning, ending: ending || self.ending, parts: parts || self.parts, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node endSource
def deconstruct_keys(_keys) { beginning: beginning, ending: ending, options: options, parts: parts, location: location, comments: comments } endSource
def format(q) braces = ambiguous?(q) || include?(%r{/}) if braces && include?(/[{}]/) q.group do q.text(beginning) q.format_each(parts) q.text(ending) end elsif braces q.group do q.text("%r{") if beginning == "/" parts.each do |part| if part.is_a?(TStringContent) q.text(part.value.gsub("\\/", "/")) else q.format(part) end end else q.format_each(parts) end q.text("}") q.text(options) end else q.group do q.text("/") q.format_each(parts) q.text("/") q.text(options) end end endSource
def options ending[1..] end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4