Sha256: 5e2590f56b0d9d1aef08449e7c10d7856d650274052148866d24362c21f5d362
Contents?: true
Size: 750 Bytes
Versions: 4
Compression:
Stored size: 750 Bytes
Contents
require_relative '../wrap' require_relative 'layer' module LovelyRufus module Layers class QuoteStripper < Layer def call(wrap) @wrap = wrap wrapped = next_layer.call(stripped_wrap) quoted = wrapped.lines.map { |line| fixed_quote + line }.join Wrap[quoted, width: wrapped.width + fixed_quote.size] end private_attr_reader :wrap private def quote starts = wrap.lines.map { |line| line[self.class::QUOTES] }.uniq starts.size == 1 ? starts.first || '' : '' end def stripped_wrap stripped_text = wrap.lines.map { |line| line[quote.size..-1] }.join Wrap[stripped_text, width: wrap.width - fixed_quote.size] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems