Class: FirstMiddleLastUngrouper

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

Instance Method Summary collapse

Constructor Details

#initialize(starting, first, middle, last, single = middle) ⇒ FirstMiddleLastUngrouper

Returns a new instance of FirstMiddleLastUngrouper.



59
60
61
62
63
64
65
# File 'lib/notroff/grouper.rb', line 59

def initialize(starting, first, middle, last, single = middle)
  super(starting)
  @first_type = first
  @middle_type = middle
  @last_type = last
  @single_type = single
end

Instance Method Details

#expand_group(group) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/notroff/grouper.rb', line 67

def expand_group(group)
  group.each_with_index do |item, i|
    if group.size == 1
      item[:type] = @single_type
    elsif i == 0
      item[:type] = @first_type
    elsif i == group.size-1
      item[:type] = @last_type
    else
      item[:type] = @middle_type
    end
  end
end