Module: BspinHelper

Defined in:
app/helpers/bspin_helper.rb

Instance Method Summary collapse

Instance Method Details

#styling(options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/bspin_helper.rb', line 2

def styling(options = {})

  options[:colour] ||= 'black'

  if options[:type] == "ball"
    sizing = "1"
  else
    sizing = "2"
  end

  case options[:size]
    when "small"
      sizing == "1" ? options[:size] = 30 : options[:size] = 5
    when "medium"
      sizing == "1" ? options[:size] = 50 : options[:size] = 11
    when "large"
      sizing == "1" ? options[:size] = 90 : options[:size] = 18
    when "x-large"
      sizing == "1" ? options[:size] = 120 : options[:size] = 25
    else
      sizing == "1" ? options[:size] = 90 : options[:size] = 18
  end

  case options[:speed]
    when "slow"
      options[:speed] = 3.0
    when "regular"
      options[:speed] = 1.7
    when "fast"
      options[:speed] = 0.5
    else
      options[:speed] = 1.7
  end

  case options[:type]
    when "ball"
      spin_type = "ball"
    when "circle1"
      spin_type = "circle1"
    when "circle1-fade"
      spin_type = "circle1-fade"
    when "circle2"
      spin_type = "circle2"
    when "bubble1"
      spin_type = "bubble1"
    when "bubble2"
      spin_type = "bubble2"
    when "bar1"
      spin_type = "bar1"
    when "bar2"
      spin_type = "bar2"
    else
      spin_type = "ball"
  end

  render partial: 'bspin/bspin', locals: { colour: options[:colour],
                                           size: options[:size],
                                           speed: options[:speed],
                                           spin_type: spin_type}
end