Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • rdoc/markup/simple_markup/fragments.rb

Files

Class/Module Index [+]

Quicksearch

SM::Fragment

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

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) click to toggle 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) click to toggle 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) click to toggle 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) click to toggle 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() click to toggle source
 
               # File rdoc/markup/simple_markup/fragments.rb, line 27
def to_s
  "L#@level: #{self.class.name.split('::')[-1]}\n#@txt"
end