Sha256: ab371e4adcb48ca938262005c3ec3f1e46df6cd00b4c95cac2e7ca1235a00ddc

Contents?: true

Size: 470 Bytes

Versions: 1

Compression:

Stored size: 470 Bytes

Contents

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| { streams: { text: line } } }
    end

    private

    attr_reader :text

    def lines
      if text.is_a?(::Array)
        text

      else
        text.split(/\n/)

      end
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.7 lib/vedeu/output/text_adaptor.rb