Class | SM::Fragment
In: | rdoc/markup/simple_markup/fragments.rb
Parent: | Object

A Fragment is a chunk of text, subclassed as a paragraph, a list entry, or verbatim text

### Methods

add_text for new to_s type_name

### Constants

TYPE_MAP | = | {} |  | This is a simple factory system that lets us associate fragement types (a string) with a subclass of fragment

### Attributes

level | [R] |
param | [R] |
txt | [R] |
type | [RW] |

### Public Class methods

for(line)

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 41
        def Fragment.for(line)
          klass =  TYPE_MAP[line.type] ||
            raise("Unknown line type: '#{line.type.inspect}:' '#{line.text}'")
          return klass.new(line.level, line.param, line.flag, line.text)
        end

new(level, param, type, txt)

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 14
        def initialize(level, param, type, txt)
          @level = level
          @param = param
          @type  = type
          @txt   = ""
          add_text(txt) if txt
        end

type_name(name)

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 37
        def Fragment.type_name(name)
          TYPE_MAP[name] = self
        end

### Public Instance methods

add_text(txt)

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 22
        def add_text(txt)
          @txt << " " if @txt.length > 0
          @txt << txt.tr_s("\n ", "  ").strip
        end

to_s()

[Source]

    # File rdoc/markup/simple_markup/fragments.rb, line 27
        def to_s
          "L#@level: #{self.class.name.split('::')[-1]}\n#@txt"
        end

[Validate]