Sha256: 498ebfb11657b407d4247efda0df9df3849c83917c1ed6515673a36907600f44
Contents?: true
Size: 1002 Bytes
Versions: 3
Compression:
Stored size: 1002 Bytes
Contents
# frozen_string_literal: true module Synvert::Core::NodeQuery::Compiler # Identifier represents a ruby identifier value. # e.g. code is `class Synvert; end`, `Synvert` is an identifier. class Identifier include Comparable # Initialize an Identifier. # @param value [String] the identifier value def initialize(value:) @value = value end # Get the actual value. # # @param node the node # @return [String|Array] # If the node is a {Parser::AST::Node}, return the node source code, # if the node is an Array, return the array of each element's actual value, # otherwise, return the String value. def actual_value(node) if node.is_a?(::Parser::AST::Node) node.to_source elsif node.is_a?(::Array) node.map { |n| actual_value(n) } else node.to_s end end # Get valid operators. def valid_operators STRING_VALID_OPERATORS end def to_s @value end end end
Version data entries
3 entries across 3 versions & 1 rubygems