class RuboCop::AST::ArrayNode
A node extension for `array` nodes. This will be used in place of a plain node when the builder constructs the AST
, making its methods available to all `array` nodes within RuboCop
.
Constants
- PERCENT_LITERAL_TYPES
Public Instance Methods
bracketed?()
click to toggle source
Checks whether the `array` literal is delimited by either percent or square brackets
@return [Boolean] whether the array is enclosed in percent or square brackets
# File lib/rubocop/ast/node/array_node.rb, line 60 def bracketed? square_brackets? || percent_literal? end
each_value(&block)
click to toggle source
@deprecated Use `values.each` (a.k.a. `children.each`)
# File lib/rubocop/ast/node/array_node.rb, line 21 def each_value(&block) return to_enum(__method__) unless block values.each(&block) self end
percent_literal?(type = nil)
click to toggle source
Checks whether the `array` literal is delimited by percent brackets.
@overload percent_literal?
Check for any percent literal.
@overload percent_literal?(type)
Check for percent literal of type `type`. @param type [Symbol] an optional percent literal type
@return [Boolean] whether the array is enclosed in percent brackets
# File lib/rubocop/ast/node/array_node.rb, line 47 def percent_literal?(type = nil) if type loc.begin && loc.begin.source =~ PERCENT_LITERAL_TYPES[type] else loc.begin&.source&.start_with?('%') end end
square_brackets?()
click to toggle source
Checks whether the `array` literal is delimited by square brackets.
@return [Boolean] whether the array is enclosed in square brackets
# File lib/rubocop/ast/node/array_node.rb, line 32 def square_brackets? loc.begin&.is?('[') end