--Apple-Mail-9-295837381
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset -ASCII;
formatðïwed
This was the first quiz I participated in (I've been waiting for one I
could whip out real quick), and it made a nice programming warm-up
after being away over the holidays. I added one small bit of
functionality: a colon, so I could do time displays. However, the colon
looked ugly when expanded, so I made it so it only expands vertically,
not horizontally.
The template-based approach I used could probably be used (with a bit
of tweaking) to allow prettier displays, but I didn't want to show off
how much I stink at ASCII art by trying myself :-)
Thanks for the quiz!
Nathaniel
Terralien, Inc.
<:((><
--Apple-Mail-9-295837381
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
x-unix-mode44;
name cd"
Content-Disposition: attachment;
filename
d
#!/usr/bin/env ruby
module LCD
class Template
def self.height(size)
3 + (2 * size)
end
def initialize(string, option)
case option
when "h"
@horizontal_stable rue
end
@lines tring.gsub(/\./, ' ').split("\n")
end
def actual_line(line, size)
case
when line 0
0
when line (self.class.height(size) - 1)
4
when line < (size + 1)
1
when line (size + 1)
2
else
3
end
end
def display(line, size)
l lines[actual_line(line, size)].dup
l[1, 1] * ize unless(@horizontal_stable)
l
end
end
TEMPLATES }
DATA.read.scan(/ ^\n])([a-z]?)\n([^ )/m){|c, option, t| TEMPLATES[c] emplate.new(t, option)}
def self.display(string, size
output "
input tring.split(//)
Template.height(size).times do |i|
line ]
input.each do |character|
line << TEMPLATES[character].display(i, size)
end
output << "#{line.join(" " * size)}\n"
end
output
end
end
if(__FILE__ $0)
require 'optparse'
size
ARGV.options do |o|
o.on("-sSIZE", "--size", Integer){|size|}
end.parse!
puts LCD::display(ARGV.first, size)
end
__END__
.-.
|.|
...
|.|
.-.
...
..|
...
..|
...
.-.
..|
.-.
|..
.-.
0.-.
..|
.-.
..|
.-.
@...
|.|
.-.
..|
...
P.-.
|..
.-.
..|
.-.
`.-.
|..
.-.
|.|
.-.
p.-.
..|
...
..|
...
-.
|.|
.-.
|.|
.-.
-.
|.|
.-.
..|
.-.
...
...
.-.
...
.-.
--Apple-Mail-9-295837381--