Class: AnbtSql::InValuesChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/anbt-sql-formatter/in_values_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(rule) ⇒ InValuesChecker

Returns a new instance of InValuesChecker.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/anbt-sql-formatter/in_values_checker.rb', line 3

def initialize(rule)
  if rule.in_values_num.nil?
    @mode = :default
  elsif rule.in_values_num == AnbtSql::Rule::ONELINE_IN_VALUES_NUM
    @mode = :oneline
    @num = rule.in_values_num
  else
    @mode = :compact
    @num = rule.in_values_num
    @counter = 0
  end
end

Instance Method Details

#checkObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/anbt-sql-formatter/in_values_checker.rb', line 16

def check
  if @mode == :default
    true
  elsif @mode == :oneline
    false
  else
    @counter += 1
    if @counter == @num
      @counter = 0
      true
    else
      false
    end
  end
end