Sha256: 4d5f9823a71e9e48ae214aa310f60c505670586e6fc5a674fc6a3cce4f69a42e

Contents?: true

Size: 1.43 KB

Versions: 123

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module RuboCop
  module AST
    # A node extension for `kwsplat` and `forwarded_kwrestarg` nodes. This will be used in
    # place of a plain node when the builder constructs the AST, making its methods available to
    # all `kwsplat` and `forwarded_kwrestarg` nodes within RuboCop.
    class KeywordSplatNode < Node
      include HashElementNode

      DOUBLE_SPLAT = '**'
      private_constant :DOUBLE_SPLAT

      # This is used for duck typing with `pair` nodes which also appear as
      # `hash` elements.
      #
      # @return [false]
      def hash_rocket?
        false
      end

      # This is used for duck typing with `pair` nodes which also appear as
      # `hash` elements.
      #
      # @return [false]
      def colon?
        false
      end

      # Returns the operator for the `kwsplat` as a string.
      #
      # @return [String] the double splat operator
      def operator
        DOUBLE_SPLAT
      end

      # Custom destructuring method. This is used to normalize the branches
      # for `pair` and `kwsplat` nodes, to add duck typing to `hash` elements.
      #
      # @return [Array<KeywordSplatNode>] the different parts of the `kwsplat`
      def node_parts
        [self, self]
      end

      # This provides `forwarded_kwrestarg` node to return true to be compatible with `kwsplat` node.
      #
      # @return [true]
      def kwsplat_type?
        true
      end
    end
  end
end

Version data entries

123 entries across 123 versions & 15 rubygems

Version Path
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/keyword_splat_node.rb