From 8436b46c1a123e6756ae1d131a493e9817627619 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 27 Sep 2010 14:36:38 -0400 Subject: [PATCH] Added Ruby version information to the output. --- src/edgecase.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/edgecase.rb b/src/edgecase.rb index e8ff9a1..658da2e 100644 --- a/src/edgecase.rb +++ b/src/edgecase.rb @@ -57,6 +57,19 @@ class Object end end +class String + def side_padding(width) + extra = width - self.size + if width < 0 + self + else + left_padding = extra / 2 + right_padding = (extra+1)/2 + (" " * left_padding) + self + (" " *right_padding) + end + end +end + module EdgeCase class << self def simple_output @@ -202,6 +215,9 @@ module EdgeCase end def artistic_end_screen + "JRuby 1.9.x Koans" + ruby_version = "(in #{'J' if defined?(JRUBY_VERSION)}Ruby #{defined?(JRUBY_VERSION) ? JRUBY_VERSION : RUBY_VERSION})" + ruby_version = ruby_version.side_padding(54) completed = <<-ENDTEXT ,, , ,, : ::::, :::, @@ -218,8 +234,8 @@ module EdgeCase ,:::::::::::, ::::::::::::, :::::::::::, ,:::::::::::: ::::::::::::: ,:::::::::::: -:::::::::::: Ruby Koans ::::::::::::, -:::::::::::: ,::::::::::::, +:::::::::::: Ruby Koans ::::::::::::, +::::::::::::#{ ruby_version },::::::::::::, :::::::::::, , :::::::::::: ,:::::::::::::, brought to you by ,,::::::::::::, :::::::::::::: ,::::::::::::