Class: Exercism::Processors::IndentationProcessor
- Defined in:
- lib/exercism-analysis/processors/indentation_processor.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ IndentationProcessor
constructor
A new instance of IndentationProcessor.
- #process_begin(exp) ⇒ Object
- #process_case(exp) ⇒ Object
- #process_if(exp) ⇒ Object (also: #process_elsif)
- #result ⇒ Object
Methods inherited from Processor
Constructor Details
#initialize ⇒ IndentationProcessor
Returns a new instance of IndentationProcessor.
18 19 20 |
# File 'lib/exercism-analysis/processors/indentation_processor.rb', line 18 def initialize @inconsistent_nodes = [] end |
Class Method Details
.inconsistent_end(*events) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/exercism-analysis/processors/indentation_processor.rb', line 6 def self.inconsistent_end(*events) events.each do |event| define_method "process_#{event}" do |exp| if inconsistent_end?(exp) @inconsistent_nodes << exp end end end end |
Instance Method Details
#process_begin(exp) ⇒ Object
40 41 42 43 44 |
# File 'lib/exercism-analysis/processors/indentation_processor.rb', line 40 def process_begin(exp) if inconsistent_end?(exp) || [exp.rescue, exp.ensure].compact.any? {|e| inconsistent?(exp, e)} @inconsistent_nodes << exp end end |
#process_case(exp) ⇒ Object
34 35 36 37 38 |
# File 'lib/exercism-analysis/processors/indentation_processor.rb', line 34 def process_case(exp) if inconsistent_end?(exp) || inconsistent_when?(exp) @inconsistent_nodes << exp end end |
#process_if(exp) ⇒ Object Also known as: process_elsif
26 27 28 29 30 |
# File 'lib/exercism-analysis/processors/indentation_processor.rb', line 26 def process_if(exp) if inconsistent_end?(exp) || (exp.else_statement && inconsistent?(exp, exp.else_statement)) @inconsistent_nodes << exp end end |
#result ⇒ Object
22 23 24 |
# File 'lib/exercism-analysis/processors/indentation_processor.rb', line 22 def result @inconsistent_nodes.select(&method(:multiple_lines?)) end |