Created
October 20, 2012 21:54
-
-
Save xaviervia/3924954 to your computer and use it in GitHub Desktop.
Matrix-like for ENV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'fast' | |
gem 'term-ansicolor' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'term/ansicolor' | |
require 'yaml' | |
require 'fast/fast' | |
class String | |
include Term::ANSIColor | |
@@used_columns = [] | |
@@max_column = `tput cols`.to_i | |
@@starting_point = 1 | |
def self.new_column | |
number = rand(1..@@max_column) | |
if @@used_columns.include? number | |
return self.new_column | |
else | |
@@used_columns << number | |
@@used_columns << (number + 1) | |
@@used_columns << (number - 1) | |
return number | |
end | |
end | |
def move x, y | |
"\033[#{x};#{y}f#{self}".green | |
end | |
def to_matrix | |
row = @@starting_point | |
column = String.new_column | |
to_print = self | |
to_print = self[0..100] if self.length > 100 | |
to_print.each_char do |char| | |
sleep 0.025 | |
print char.move row, column | |
row += 1 | |
end | |
print "\033M" | |
end | |
end | |
puts "\033[2J" # Clear screen and home cursor | |
env = Fast.file 'env' | |
env.delete! | |
ENV.each do |key, value| | |
env << "#{key}: #{value}\n" | |
end | |
ENV.each do |key, value| | |
"#{key}▊#{value}".to_matrix | |
end | |
puts | |
puts | |
Process.exit! | |
row = 1 | |
column = 5 | |
"My tweet is giving me déjà vu".each_char do |letter| | |
sleep 0.2 | |
print letter.move row, column | |
row += 1 | |
end | |
puts | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment