Sha256: 35c857fb40c6256ec8fe11e7115d4e7a429e378a97cdf45bdf034838c20ea9c5
Contents?: true
Size: 773 Bytes
Versions: 1
Compression:
Stored size: 773 Bytes
Contents
# frozen_string_literal: true 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lovely_rufus-1.0.1 | lib/lovely_rufus/layers/quote_stripper.rb |