Sha256: 589c660108ea465a0c96d9c6bc30a51ec068085f8a168b02acabcb1341653c5e
Contents?: true
Size: 773 Bytes
Versions: 4
Compression:
Stored size: 773 Bytes
Contents
require "kagami/version" module Kagami class << self def max_width(line) return line.lines.map{|x| x.chomp.size}.max end def ljust(line) width = max_width(line) return line.lines.map{|x| x.chomp.ljust(width)}.join("\n") end def reversed(line) return line.lines.map{|x| x.chomp.reverse}.join("\n") end def readable(line) return line.gsub(/(\w+(:? \w+)*)/){|s| s.reverse} end def convert(line) # Align string aligned_line = ljust(line) # Reverse reversed_line = reversed(aligned_line) # Rereverse readable words only!!!!! readable_line = readable(reversed_line) return readable_line end def run(source) puts convert(source) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kagami-0.1.4 | lib/kagami.rb |
kagami-0.1.3 | lib/kagami.rb |
kagami-0.1.0 | lib/kagami.rb |
kagami-0.0.1 | lib/kagami.rb |