Sha256: e32241303e4fe465c22d214d446ce57cb0ad354fd4eaad343c6084d586d47f5d

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

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

      # Returns the keyword of the `until` statement as a string.
      #
      # @return [String] the keyword of the `until` statement
      def keyword
        'until'
      end

      # Returns the inverse keyword of the `until` node as a string.
      # Returns `while` for `until` nodes and vice versa.
      #
      # @return [String] the inverse keyword of the `until` statement
      def inverse_keyword
        'while'
      end

      # Checks whether the `until` node has a `do` keyword.
      #
      # @return [Boolean] whether the `until` node has a `do` keyword
      def do?
        loc_is?(:begin, 'do')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-ast-1.37.0 lib/rubocop/ast/node/until_node.rb