Method: Olivander::ApplicationHelper#chart_column_class_num

Defined in:
app/helpers/olivander/application_helper.rb

#chart_column_class_num(label, count, min) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/olivander/application_helper.rb', line 3

def chart_column_class_num(label, count, min)
  return "col-#{label}-#{min}" if count >= 12

  modded = count % 12
  divisor = modded.zero? ? 1 : modded
  "col-#{label}-#{[12 / divisor, min].max}"

  divisor = count
  result = 12 / divisor
  while result < min
    divisor /= 2
    result = 12 / divisor
  end
  "col-#{label}-#{result}"
end