Class: RuboCop::Cop::PreferredDelimiters

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/mixin/preferred_delimiters.rb

Overview

Common functionality for handling percent literal delimiters.

Constant Summary collapse

PERCENT_LITERAL_TYPES =
%w[% %i %I %q %Q %r %s %w %W %x].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, config, preferred_delimiters) ⇒ PreferredDelimiters

Returns a new instance of PreferredDelimiters.



11
12
13
14
15
# File 'lib/rubocop/cop/mixin/preferred_delimiters.rb', line 11

def initialize(type, config, preferred_delimiters)
  @type = type
  @config = config
  @preferred_delimiters = preferred_delimiters
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/rubocop/cop/mixin/preferred_delimiters.rb', line 7

def config
  @config
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/rubocop/cop/mixin/preferred_delimiters.rb', line 7

def type
  @type
end

Instance Method Details

#delimitersObject



17
18
19
# File 'lib/rubocop/cop/mixin/preferred_delimiters.rb', line 17

def delimiters
  preferred_delimiters[type].split(//)
end