Class: Yalphabetize::FileYalphabetizer

Inherits:
Object
  • Object
show all
Defined in:
lib/yalphabetize/file_yalphabetizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_path, **options) ⇒ FileYalphabetizer

Returns a new instance of FileYalphabetizer.



5
6
7
8
9
10
11
12
13
14
# File 'lib/yalphabetize/file_yalphabetizer.rb', line 5

def initialize(file_path, **options)
  @file_path = file_path
  @reader_class = options[:reader_class]
  @offence_detector_class = options[:offence_detector_class]
  @logger = options[:logger]
  @autocorrect = options[:autocorrect]
  @alphabetizer_class = options[:alphabetizer_class]
  @writer_class = options[:writer_class]
  @order_checker_class = options[:order_checker_class]
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
# File 'lib/yalphabetize/file_yalphabetizer.rb', line 16

def call
  if offences?
    logger.log_offence(file_path)
    autocorrect_file if autocorrect
  else
    logger.log_no_offence
  end
end