Sha256: de42bf20ff584aac4fc00a63586f9527cb5699f8ab68e42daab6f161135bb449

Contents?: true

Size: 468 Bytes

Versions: 6

Compression:

Stored size: 468 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

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.1.6 lib/vedeu/output/text_adaptor.rb
vedeu-0.1.5 lib/vedeu/output/text_adaptor.rb
vedeu-0.1.4 lib/vedeu/output/text_adaptor.rb
vedeu-0.1.3 lib/vedeu/output/text_adaptor.rb
vedeu-0.1.2 lib/vedeu/output/text_adaptor.rb
vedeu-0.1.1 lib/vedeu/parsing/text_adaptor.rb