Class: FirstMiddleLastUngrouper
- Inherits:
-
Object
- Object
- FirstMiddleLastUngrouper
- Defined in:
- lib/notroff/grouper.rb
Instance Method Summary collapse
- #expand_group(group) ⇒ Object
-
#initialize(starting, first, middle, last, single = middle) ⇒ FirstMiddleLastUngrouper
constructor
A new instance of FirstMiddleLastUngrouper.
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 (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 |