class RuboCop::Cop::SpaceInside::Brackets
Wraps info about the brackets. Makes it easy to check whether a token is one of the brackets.
@example Parentheses `()`
Brackets.new(:tLPAREN, :tRPAREN, 'parentheses')
@example Square brackets `[]`
Brackets.new([:tLBRACK, :tLBRACK2], :tRBRACK, 'square brackets')
Attributes
kind[R]
Public Class Methods
new(left, right, kind)
click to toggle source
# File lib/rubocop/cop/mixin/space_inside.rb, line 57 def initialize(left, right, kind) @left_side_types = [left].flatten @right_side_type = right @kind = kind end
Public Instance Methods
left_side?(token)
click to toggle source
# File lib/rubocop/cop/mixin/space_inside.rb, line 63 def left_side?(token) # Left side bracket has to be able to match multiple types # (e.g. :tLBRACK and :tLBRACK2) @left_side_types.include?(token.type) end
right_side?(token)
click to toggle source
# File lib/rubocop/cop/mixin/space_inside.rb, line 69 def right_side?(token) @right_side_type == token.type end