Created
December 18, 2009 08:15
-
-
Save jeroenvandijk/259360 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
module Chars | |
def scale(chars, scale) | |
print_chars scale_vertically(scale_horizontally(chars, scale), scale) | |
end | |
private | |
def chars | |
@chars ||= [ | |
[ | |
" |", | |
" |", | |
" |", | |
" |", | |
" |" | |
], | |
[ | |
" - ", | |
" |", | |
" - ", | |
"| ", | |
" _ " | |
], | |
[ | |
" - ", | |
" |", | |
" - ", | |
" |", | |
" _ " | |
] | |
] | |
end | |
def char(i) | |
chars[i - 1] | |
end | |
def scale_horizontally(chars, scale) | |
chars.map do |row| | |
row.map do |cell| | |
[0, [1] * scale, 2].flatten.map { |i| cell[i] } | |
end | |
end | |
end | |
def scale_vertically(chars, scale) | |
chars.map do |row| | |
[0, [1] * scale, 2, [3] * scale, 4].flatten.map { |i| row[i] } | |
end | |
end | |
def print_chars(chars) | |
puts chars.map { |row| row.map{ |col| col.join } }.join("\n") | |
end | |
end | |
unless @loaded | |
@loaded = true | |
require 'rubygems' | |
require 'boson' | |
require 'boson/runners/bin_runner' | |
# Boson.commands << Char | |
Boson::Repo | |
# load_library(Chars, Chars.public_methods) | |
Boson::BinRunner.start | |
Boson::Manager.load(Chars, :commands => Chars.public_methods) | |
end | |
# include Chars | |
# | |
# chars = [1, 2, 3].map { |x| char(x).map { |row| row.split("") } } | |
# scale(chars, 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment