Class | SM::Fragment |
In: |
markup/simple_markup/fragments.rb
|
Parent: | Object |
A Fragment is a chunk of text, subclassed as a paragraph, a list entry, or verbatim text
TYPE_MAP | = | {} | This is a simple factory system that lets us associate fragement types (a string) with a subclass of fragment |
level | [R] | |
param | [R] | |
txt | [R] | |
type | [RW] |
# File markup/simple_markup/fragments.rb, line 41 41: def Fragment.for(line) 42: klass = TYPE_MAP[line.type] || 43: raise("Unknown line type: '#{line.type.inspect}:' '#{line.text}'") 44: return klass.new(line.level, line.param, line.flag, line.text) 45: end
# File markup/simple_markup/fragments.rb, line 14 14: def initialize(level, param, type, txt) 15: @level = level 16: @param = param 17: @type = type 18: @txt = "" 19: add_text(txt) if txt 20: end
# File markup/simple_markup/fragments.rb, line 37 37: def Fragment.type_name(name) 38: TYPE_MAP[name] = self 39: end