From b30355b50f72887f388c66e5c59971c9f7a940e1 Mon Sep 17 00:00:00 2001 From: Stormwind Date: Tue, 8 Dec 2015 11:49:08 +0100 Subject: [PATCH] Add support for ascii output with various symbol amount The support for different chars in the output array was former restricted to 10. But this is not necessary in the code. So I changed that. As example I've added the alphabet. --- lib/rubella/output/ascii.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/rubella/output/ascii.rb b/lib/rubella/output/ascii.rb index b7de095..6619c4b 100644 --- a/lib/rubella/output/ascii.rb +++ b/lib/rubella/output/ascii.rb @@ -37,6 +37,10 @@ module Rubella [" ", "ยท", ",", ";", "o", "O", "%", "8", "@", "#"] @symbols["numbers"] = [" ", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + @symbols["letters"] = + [" ", "a", "b", "c", "d", "e", "f", "g", "h", + "i", "j", "k", "l", "m", "n", "o", "p", "q", + "r", "s", "t", "u", "v", "w", "x", "y", "z"] self.used_symbols = "shades_ascii" super data, field_size @@ -81,12 +85,12 @@ module Rubella @data.each do |point| i = 0 point.reverse.each do |part| - part = (part*10).to_i + part = (part*@symbols[@used_symbols].length).to_i # Fix to prevent possible overflow.. should never happen, but we # are careful - if part > 9 - part = 9 + if part > (@symbols[@used_symbols].length-1) + part = (@symbols[@used_symbols].length-1) end ascii_arr[i] << @symbols[@used_symbols][part]