Class: CsvCop::Cop::Lint::DeplicatedElementInOneColumn

Inherits:
Cop
  • Object
show all
Defined in:
lib/csvcop/cop/uniq_column.rb

Constant Summary collapse

MSG =
'Column is must uniq element.'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cop

#on_ensure_all

Constructor Details

#initialize(csv, config) ⇒ DeplicatedElementInOneColumn

Returns a new instance of DeplicatedElementInOneColumn.



7
8
9
10
# File 'lib/csvcop/cop/uniq_column.rb', line 7

def initialize(csv, config)
  @csv = csv
  @config = config
end

Class Method Details

.config_keyObject



16
17
18
# File 'lib/csvcop/cop/uniq_column.rb', line 16

def self.config_key
  self.name.split("::").last.to_sym
end

.enable?(config) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/csvcop/cop/uniq_column.rb', line 12

def self.enable?(config)
  config[:AllCops][config_key][:Enable]
end

Instance Method Details

#runObject



20
21
22
23
# File 'lib/csvcop/cop/uniq_column.rb', line 20

def run
  return false unless DeplicatedElementInOneColumn.enable?(@config)
  on_ensure
end