ruby version - start with copies of *[hc]pp in ruby/, rename main.cpp -> warciv.rb, v0draft readme
merge hpp & cpp files into rb

for h in *hpp; do c=$(echo $h | sed 's/hpp$/cpp/'); r=$(echo $h | sed 's/hpp$/rb/'); cat $h > $r && rm -v $h; cat $c >> $r && rm -v $c; done
remove hpp ifndefs

perl -i -ne 'print unless /^#.*__[A-Z_]*__$/' *rb
not ruby yet comments

sed -i '1i# not ruby yet!' *.rb
zruseny cpp direktivy, forward classy; include->reqiure *rb

sed -i '/^class.*;/d' *rb
sed -i 's/^#include "\(.*\).hpp"$/require '\''.\/\1.rb'\''/' *rb
sed -i '/^#include/d' *rb
comments and class end
class beginning

 sed -i 's/^class \([a-zA-Z]*\) {$/class \1/' *rb
 sed -i 's/^class \([a-zA-Z]*\) : [a-z]\+ \([a-zA-Z]*\) {$/class \1 < \2/' *rb
atribute access to @attr, method to self.meth, this to self, -> to ., no trailing semicolon, no namespaces

perl -i -npe 's/this->([\w_]++)(?!\s*\()/\@$1$2/g' *.rb
perl -i -npe 's/this->/self./g' *.rb
perl -i -npe 's/\bthis\b/self/g' *.rb
sed -i 's/->/./g' *.rb
 sed -i 's/;$//'  *.rb
 sed -i '/using namespace/d' *
delete delete; new Foo( -> Foo.new( ; *foo -> foo; NULL -> nil

 perl -i -npe 's/\bnew (.*?)\s*\(/$1.new(/g' *.rb
 perl -i -ne 'print unless /^\s*delete /' *rb
  perl -i -npe 's/\*(\S)/$1/g' *rb
   perl -i -npe 's/\b(NULL|nullptr)\b/nil/g' *rb
no externs; no require self

for f in *; do perl -i -ne "print unless m#require './$f'#" $f; done
 sed -i '/extern/d' *rb
requires to the front

for f in *rb; do perl -e '@f=<>; print join("", sort { $a cmp $b } grep { /\brequire\b/ } @f); print join("", grep { $_ !~ /\brequire\b/ } @f);' $f > tmp.$f; mv tmp.$f $f; done
fix warciv.rb
foreach to each, manually fix stray ends; } -> end

 perl -i -npe 'next unless /for \(\w+ (\w+) : (.*)\)( {)?$/; my ($pfx, $var, $src, $brace) = ($`, $1, $2, $3); $_ = $pfx.$src.".each do |".$var."|\n"; if (!$brace) { $_ .= <> . $pfx . "end\n"; }' *.rb
 # +fixup for()if()foo -> each()if()ENDfoo

 sed -i 's/^\(\s*\)}$/\1end/' *.rb
std::, classs::method prefixes

perl -i -npe 's/^\w+:://; s/\bstd:://g' *.rb
single or double nonspecial words means type and decl - remove; also private:..

perl -i -ne 'print unless /^\s*\w+(?<!class)(?<!return)(?<!throw)(?<!break)(?<!end)(?<!continue)( \w+)?$/' *rb
 perl -i -ne 'print unless /^(private|public|protected):$/' *rb
defs

perl -i -npe 's/^(\s*)(\w+ )*(\w+\([^{:]*\)) {$/$1def $3/' *.rb
fix foreach, no spc needed b4 :
remove more type info

perl -i -npe 'sub p { join ", ", map { s/(\w+) (\w+)/$2/r } split /,\s*/, shift }; s/\(((\w+ \w+, )*)(\w+ \w+)\)/"(".p($1.$3).")"/e' *.rb
del create fac ptrn

sed -i '/static.*create/d' *rb
fixes v ami