Sha256: 88d47d9382f8c8b35cf41ad0c5fa198182401c426fe1c5b46ea8ae4054d7c754

Contents?: true

Size: 770 Bytes

Versions: 6

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

module Synvert::Core::NodeQuery::Compiler
  # String represents a ruby string value.
  class String
    include Comparable

    # Initialize a String.
    # @param value [String] the string value
    def initialize(value:)
      @value = value
    end

    # Get valid operators.
    def valid_operators
      SIMPLE_VALID_OPERATORS
    end

    # Get the actual value of a node.
    # @param node [Parser::AST::Node] the node
    # @return [String] if node is a Parser::AST::Node, return the node source code, otherwise, return the string value.
    def actual_value(node)
      if node.is_a?(::Parser::AST::Node)
        node.to_source
      else
        node.to_s
      end
    end

    def to_s
      "\"#{@value}\""
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
synvert-core-1.1.0 lib/synvert/core/node_query/compiler/string.rb
synvert-core-1.0.5 lib/synvert/core/node_query/compiler/string.rb
synvert-core-1.0.4 lib/synvert/core/node_query/compiler/string.rb
synvert-core-1.0.3 lib/synvert/core/node_query/compiler/string.rb
synvert-core-1.0.2 lib/synvert/core/node_query/compiler/string.rb
synvert-core-1.0.1 lib/synvert/core/node_query/compiler/string.rb