Class SM::LineCollection
In: markup/simple_markup/fragments.rb
Parent: Object

Collect groups of lines together. Each group will end up containing a flow of text

Methods

accept   add   each   fragment_for   new   normalize   to_a   to_s  

Public Class methods

[Source]

     # File markup/simple_markup/fragments.rb, line 127
127:     def initialize
128:       @fragments = []
129:     end

Public Instance methods

[Source]

     # File markup/simple_markup/fragments.rb, line 161
161:     def accept(am, visitor)
162: 
163:       visitor.start_accepting
164: 
165:       @fragments.each do |fragment|
166:         case fragment
167:         when Verbatim
168:           visitor.accept_verbatim(am, fragment)
169:         when Rule
170:           visitor.accept_rule(am, fragment)
171:         when ListStart
172:           visitor.accept_list_start(am, fragment)
173:         when ListEnd
174:           visitor.accept_list_end(am, fragment)
175:         when ListItem
176:           visitor.accept_list_item(am, fragment)
177:         when BlankLine
178:           visitor.accept_blank_line(am, fragment)
179:         when Heading
180:           visitor.accept_heading(am, fragment)
181:         when Paragraph
182:           visitor.accept_paragraph(am, fragment)
183:         end
184:       end
185: 
186:       visitor.end_accepting
187:     end

[Source]

     # File markup/simple_markup/fragments.rb, line 131
131:     def add(fragment)
132:       @fragments << fragment
133:     end

[Source]

     # File markup/simple_markup/fragments.rb, line 135
135:     def each(&b)
136:       @fragments.each(&b)
137:     end

Factory for different fragment types

[Source]

     # File markup/simple_markup/fragments.rb, line 145
145:     def fragment_for(*args)
146:       Fragment.for(*args)
147:     end

tidy up at the end

[Source]

     # File markup/simple_markup/fragments.rb, line 150
150:     def normalize
151:       change_verbatim_blank_lines
152:       add_list_start_and_ends
153:       add_list_breaks
154:       tidy_blank_lines
155:     end

For testing

[Source]

     # File markup/simple_markup/fragments.rb, line 140
140:     def to_a
141:       @fragments.map {|fragment| fragment.to_s}
142:     end

[Source]

     # File markup/simple_markup/fragments.rb, line 157
157:     def to_s
158:       @fragments.join("\n----\n")
159:     end

[Validate]