Class: SM::LineCollection

Class | SM::LineCollection
In: | rdoc/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

new()

[Source]

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

### Public Instance methods

accept(am, visitor)

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 161
        def accept(am, visitor)

          visitor.start_accepting

          @fragments.each do |fragment|
            case fragment
            when Verbatim
              visitor.accept_verbatim(am, fragment)
            when Rule
              visitor.accept_rule(am, fragment)
            when ListStart
              visitor.accept_list_start(am, fragment)
            when ListEnd
              visitor.accept_list_end(am, fragment)
            when ListItem
              visitor.accept_list_item(am, fragment)
            when BlankLine
              visitor.accept_blank_line(am, fragment)
            when Heading
              visitor.accept_heading(am, fragment)
            when Paragraph
              visitor.accept_paragraph(am, fragment)
            end
          end

          visitor.end_accepting
        end

add(fragment)

[Source]

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

each(&b)

[Source]

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

fragment_for(*args)

Factory for different fragment types

[Source]

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

normalize()

tidy up at the end

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 150
        def normalize
          change_verbatim_blank_lines
          add_list_start_and_ends
          add_list_breaks
          tidy_blank_lines
        end

to_a()

For testing

[Source]

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

to_s()

[Source]

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

[Validate]