Sha256: 42633537355787b90be91af6c4304868a542719407a3ce060cefbe2cfbccaecd

Contents?: true

Size: 448 Bytes

Versions: 3

Compression:

Stored size: 448 Bytes

Contents

require_relative '../models/line'

module Vedeu
  class TextAdaptor
    def self.adapt(text)
      new(text).adapt
    end

    def initialize(text)
      @text = text
    end

    def adapt
      return [] if no_content?

      lines.map { |line| Line.new({ streams: { text: line } }) }
    end

    private

    attr_reader :text

    def lines
      text.split(/\n/)
    end

    def no_content?
      text.nil? || text.empty?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.0.30 lib/vedeu/output/text_adaptor.rb
vedeu-0.0.29 lib/vedeu/output/text_adaptor.rb
vedeu-0.0.28 lib/vedeu/output/text_adaptor.rb