Sha256: 1643401b0423331ea138e3ed3d080a9428d3b0f995904005de474daffc030f2c
Contents?: true
Size: 1002 Bytes
Versions: 9
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 SIMPLE_VALID_OPERATORS end def to_s @value end end end
Version data entries
9 entries across 9 versions & 1 rubygems