1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
# frozen_string_literal: true
module RuboCop
module AST
# A node extension for `kwsplat` nodes. This will be used in place of a
# plain node when the builder constructs the AST, making its methods
# available to all `kwsplat` nodes within RuboCop.
class KeywordSplatNode < Node
include HashElementNode
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
end
end
end
|