Class: Vedeu::TextAdaptor

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/parsing/text_adaptor.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ TextAdaptor

Returns a new instance of TextAdaptor.



13
14
15
# File 'lib/vedeu/parsing/text_adaptor.rb', line 13

def initialize(text)
  @text = text
end

Class Method Details

.adapt(text) ⇒ Array

Convert a block of text into a collection of lines.

Parameters:

  • text (String|Array)

    a block of text containing new line (n) characters, or a collection of strings.

Returns:

  • (Array)


9
10
11
# File 'lib/vedeu/parsing/text_adaptor.rb', line 9

def self.adapt(text)
  new(text).adapt
end

Instance Method Details

#adaptObject



17
18
19
20
21
# File 'lib/vedeu/parsing/text_adaptor.rb', line 17

def adapt
  return [] if no_content?

  lines.map { |line| { streams: { text: line } } }
end