Created
June 2, 2012 05:11
-
-
Save takai/2856693 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
module Amida | |
class App | |
START_CHAR = 65 | |
def header(column) | |
chars = (START_CHAR...(START_CHAR + column)).map(&:chr) | |
chars.join(' ') + "\n" + | |
bar_row_string(column) | |
end | |
def row(column) | |
bar = rand(column - 1) | |
(0...column).each_with_object("") do |i, r| | |
r << if i == bar | |
"|--" | |
else | |
"| " | |
end | |
end | |
end | |
def footer(column) | |
win_rows = ([" "] * column).tap { |r| r[rand(column)] = "*" } | |
win_row_string = win_rows.join(' ') | |
"#{bar_row_string(column)}\n#{win_row_string}" | |
end | |
def run | |
num = 10 | |
column = 5 | |
puts header(column) | |
num.times do | |
puts row(column) | |
end | |
puts footer(column) | |
end | |
private | |
def bar_row_string(column) | |
(["|"] * column).join(' ') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment