Sha256: 027173240f6b1cf9e0fb8b86af46dfb645c05f2c1b99542d5d51fcafbb934e77
Contents?: true
Size: 794 Bytes
Versions: 1
Compression:
Stored size: 794 Bytes
Contents
require_relative "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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kagami-0.1.5 | lib/kagami.rb |