Bratish Goswami

Personal website and blog

Ruby ASCII Art for Company Tagline

My employer was looking for some cool idea for company's tagline and T-shirt prints for upcoming RubyConfIndia.

Here's what I came up with: a small obfuscated ruby snippet showing abbreviated organization name as an ascii art and outputs the endearing nickname as a string.

" ..1'''.1 '00''0.   '1|''|.   ''1|''
  11    '0  00   ||   ||   0     1|
.1'     '1  10   ||   ||   01    |1  
.1'         11   0    1|   0     |0
|1|         101'1'    |0'0|'     ||  
|11         00  1     |0  1      ||  
'11     .'  10  01    ||  |0     ||  
'11     ||  01   11   ||   '1    ||  
 11     ||  0|   .0|  |0    11   ||
 ''1....1' .||.  '01'.||.  '|0'..11..
".split("\n").collect{|x| Integer("0b#{x.gsub(/[ \.'\|]/, "")}").chr}.join
#=> castlerock

How it works

Let's break down each operation:

  1. .split("\n") - Takes the multi-line ASCII art string and splits it into an array of lines
  2. .collect{|x| ... } - Processes each line individually (x is each line)
  3. x.gsub(/[ \.'\|]/, "") - Removes all visual characters (spaces, dots, quotes, pipes) from each line using regex
  4. Integer("0b#{...}") - Converts the remaining 0s and 1s into a binary number (0b prefix tells Ruby it's binary)
  5. .chr - Converts each binary number into its corresponding ASCII character
  6. .join - Combines all the characters into a single string

So the ASCII art shows our company abbreviation visually, but the hidden binary data (the 0s and 1s) spells out our nickname when you run the code.