Class: RuboCop::Cop::SpaceInside::Brackets
- Inherits:
-
Object
- Object
- RuboCop::Cop::SpaceInside::Brackets
- Defined in:
- lib/rubocop/cop/mixin/space_inside.rb
Overview
Wraps info about the brackets. Makes it easy to check whether a token is one of the brackets.
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
Instance Method Summary collapse
-
#initialize(left, right, kind) ⇒ Brackets
constructor
A new instance of Brackets.
- #left_side?(token) ⇒ Boolean
- #right_side?(token) ⇒ Boolean
Constructor Details
#initialize(left, right, kind) ⇒ Brackets
Returns a new instance of Brackets.
58 59 60 61 62 |
# File 'lib/rubocop/cop/mixin/space_inside.rb', line 58 def initialize(left, right, kind) @left_side_types = [left].flatten @right_side_type = right @kind = kind end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
56 57 58 |
# File 'lib/rubocop/cop/mixin/space_inside.rb', line 56 def kind @kind end |
Instance Method Details
#left_side?(token) ⇒ Boolean
64 65 66 67 68 |
# File 'lib/rubocop/cop/mixin/space_inside.rb', line 64 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) ⇒ Boolean
70 71 72 |
# File 'lib/rubocop/cop/mixin/space_inside.rb', line 70 def right_side?(token) @right_side_type == token.type end |