123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Cop::Style::BisectedAttrAccessor::Macro Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/rubocop/cop/style/bisected_attr_accessor/macro.rb

Overview

Representation of an attr_reader, attr_writer or attr macro for use by Style/BisectedAttrAccessor.

Constant Summary

::RuboCop::Cop::VisibilityHelp - Included

VISIBILITY_SCOPES

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.macro?(node) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 15

def self.macro?(node)
  node.method?(:attr_reader) || node.method?(:attr_writer) || node.method?(:attr)
end

Instance Attribute Details

#all_bisected?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 49

def all_bisected?
  rest.none?
end

#attrs (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 13

attr_reader :node, :attrs, :bisection

#bisection (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 13

attr_reader :node, :attrs, :bisection

#node (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 13

attr_reader :node, :attrs, :bisection

#reader?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 41

def reader?
  node.method?(:attr_reader) || node.method?(:attr)
end

#writer?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 45

def writer?
  node.method?(:attr_writer)
end

Instance Method Details

#attr_names

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 29

def attr_names
  @attr_names ||= attrs.keys
end

#bisect(*names)

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 25

def bisect(*names)
  @bisection = attrs.slice(*names).values
end

#bisected_names

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 33

def bisected_names
  bisection.map(&:source)
end

#rest

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 53

def rest
  @rest ||= attr_names - bisected_names
end

#visibility

[ GitHub ]

  
# File 'lib/rubocop/cop/style/bisected_attr_accessor/macro.rb', line 37

def visibility
  @visibility ||= node_visibility(node)
end