Class: ParagraphJoiner

Inherits:
Object
  • Object
show all
Defined in:
lib/notroff/paragraph_joiner.rb

Direct Known Subclasses

BodyParagraphJoiner, CodeParagraphJoiner

Instance Method Summary collapse

Instance Method Details

#join(first, second) ⇒ Object



26
27
28
# File 'lib/notroff/paragraph_joiner.rb', line 26

def join(first, second)
  first + " " + second
end

#join?(paragraph) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/notroff/paragraph_joiner.rb', line 30

def join?(paragraph)
  false
end

#process(paragraphs) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/notroff/paragraph_joiner.rb', line 2

def process( paragraphs )
  processed_paragraphs = []
  new_p = nil
  paragraphs.each do |paragraph|
    do_join = join?(paragraph)

    if join?(paragraph)
      if new_p
        new_p.string = join(new_p.string, paragraph)
      else
        new_p = paragraph
      end
    else
      if new_p
        processed_paragraphs << new_p
        new_p = nil
      end
      processed_paragraphs << paragraph unless skip?(paragraph)
    end
  end
  processed_paragraphs << new_p if new_p
  processed_paragraphs
end

#skip?(paragraph) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/notroff/paragraph_joiner.rb', line 34

def skip?(paragraph)
  false
end