Class: Ungrouper

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

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Ungrouper

Returns a new instance of Ungrouper.



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

def initialize(type)
  @type = type
end

Instance Method Details

#expand_group(group) ⇒ Object



53
54
55
# File 'lib/notroff/grouper.rb', line 53

def expand_group(group)
  group
end

#process(paragraphs) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/notroff/grouper.rb', line 38

def process( paragraphs )
  processed = []

  paragraphs.each do |para|
    if para[:type] != :group
      processed << para
    elsif para[:kid_type] != @type
      processed << para
    else
      kids = expand_group(para[:kids])
      processed.add_all(kids) if kids
    end
  end
end