app/helpers/bspin_helper.rb in bspin-1.0.1 vs app/helpers/bspin_helper.rb in bspin-1.1.0
- old
+ new
@@ -1,27 +1,34 @@
module BspinHelper
+
def styling(options = {})
+ options[:colour] = options[:color] if options.has_key?(:color)
options[:colour] ||= 'black'
+ options[:type] ||= 'ball'
+ options[:type] = "ball" if !["ball", "circle1", "circle1-fade", "circle2",
+ "bubble1", "bubble2", "bar1", "bar2"].include? options[:type]
- if options[:type] == "ball"
- sizing = "1"
- else
- sizing = "2"
- end
+ colour = Color::CSS[options[:colour]]
+ colour = Color::RGB.from_html(options[:colour]) if colour.blank?
+ red = colour.red.to_i
+ green = colour.green.to_i
+ blue = colour.blue.to_i
+ sizing = ( options[:type] == "ball" ? "1" : "2" )
+
case options[:size]
when "small"
- sizing == "1" ? options[:size] = 30 : options[:size] = 5
+ options[:size] = ( sizing == "1" ? 30 : 5 )
when "medium"
- sizing == "1" ? options[:size] = 50 : options[:size] = 11
+ options[:size] = ( sizing == "1" ? 50 : 11 )
when "large"
- sizing == "1" ? options[:size] = 90 : options[:size] = 18
+ options[:size] = ( sizing == "1" ? 90 : 18 )
when "x-large"
- sizing == "1" ? options[:size] = 120 : options[:size] = 25
+ options[:size] = ( sizing == "1" ? 120 : 25 )
else
- sizing == "1" ? options[:size] = 90 : options[:size] = 18
+ options[:size] = ( sizing == "1" ? 90 : 18 )
end
case options[:speed]
when "slow"
options[:speed] = 3.0
@@ -31,32 +38,14 @@
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}
+ spin_type: options[:type],
+ red: red,
+ green: green,
+ blue: blue }
end
end
\ No newline at end of file