From 74016715dfe7b9a32d2a2f080afbf1bd71351332 Mon Sep 17 00:00:00 2001 From: Stormwind Date: Sun, 22 Feb 2015 22:12:28 +0100 Subject: [PATCH] Improve math and erase case-selection Now mathematics does the job ob the case statemant. --- lib/rubella/output/ascii.rb | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/rubella/output/ascii.rb b/lib/rubella/output/ascii.rb index c1b3cd3..fc0994f 100644 --- a/lib/rubella/output/ascii.rb +++ b/lib/rubella/output/ascii.rb @@ -30,30 +30,15 @@ module Rubella parsed_list.each do |point| i = 0 point.reverse.each do |part| - part = (part*100).to_i + part = (part*10).to_i - case part - when 0..10 then - ascii_arr[i] << @symbols[@used_symbols][0] - when 11..20 then - ascii_arr[i] << @symbols[@used_symbols][1] - when 21..30 then - ascii_arr[i] << @symbols[@used_symbols][2] - when 31..40 then - ascii_arr[i] << @symbols[@used_symbols][3] - when 41..50 then - ascii_arr[i] << @symbols[@used_symbols][4] - when 51..60 then - ascii_arr[i] << @symbols[@used_symbols][5] - when 61..70 then - ascii_arr[i] << @symbols[@used_symbols][6] - when 71..80 then - ascii_arr[i] << @symbols[@used_symbols][7] - when 81..90 then - ascii_arr[i] << @symbols[@used_symbols][8] - else - ascii_arr[i] << @symbols[@used_symbols][9] + # Fix to prevent possible overflow.. should never happen, but we + # are careful + if part > 9 + part = 9 end + + ascii_arr[i] << @symbols[@used_symbols][part] i = i+1 end end