Sha256: 24eafcf1208554ef2b3a9aba77106dc6e192f5fee0c8d147a2e2d340251b2fe7

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

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

      # The method name of this `super` node. Always `:super`.
      #
      # @return [Symbol] the method name of `super`
      def method_name
        :super
      end

      # An array containing the arguments of the super invocation.
      #
      # @return [Array<Node>] the arguments of the super invocation
      def arguments
        node_parts
      end

      # Checks whether the method name matches the argument.
      #
      # @param [Symbol, String] name the method name to check for
      # @return [Boolean] whether the method name matches the argument
      def method?(name)
        method_name == name.to_sym
      end

      # Custom destructuring method. This can be used to normalize
      # destructuring for different variations of the node.
      #
      # @return [Array] the different parts of the `block` node
      def node_parts
        to_a
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.49.1 lib/rubocop/ast/node/super_node.rb
rubocop-0.49.0 lib/rubocop/ast/node/super_node.rb