Class: SM::Fragment
- Inherits:
-
Object
- Object
- SM::Fragment
- Defined in:
- lib/rdoc/markup/simple_markup/fragments.rb
Overview
A Fragment is a chunk of text, subclassed as a paragraph, a list entry, or verbatim text
Constant Summary collapse
- TYPE_MAP =
This is a simple factory system that lets us associate fragement types (a string) with a subclass of fragment
{}
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
-
#txt ⇒ Object
readonly
Returns the value of attribute txt.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #add_text(txt) ⇒ Object
-
#initialize(level, param, type, txt) ⇒ Fragment
constructor
A new instance of Fragment.
- #to_s ⇒ Object
Constructor Details
#initialize(level, param, type, txt) ⇒ Fragment
Returns a new instance of Fragment.
14 15 16 17 18 19 20 |
# File 'lib/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 |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level
11 12 13 |
# File 'lib/rdoc/markup/simple_markup/fragments.rb', line 11 def level @level end |
#param ⇒ Object (readonly)
Returns the value of attribute param
11 12 13 |
# File 'lib/rdoc/markup/simple_markup/fragments.rb', line 11 def param @param end |
#txt ⇒ Object (readonly)
Returns the value of attribute txt
11 12 13 |
# File 'lib/rdoc/markup/simple_markup/fragments.rb', line 11 def txt @txt end |
#type ⇒ Object
Returns the value of attribute type
12 13 14 |
# File 'lib/rdoc/markup/simple_markup/fragments.rb', line 12 def type @type end |
Class Method Details
Instance Method Details
#add_text(txt) ⇒ Object
22 23 24 25 |
# File 'lib/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 ⇒ Object
27 28 29 |
# File 'lib/rdoc/markup/simple_markup/fragments.rb', line 27 def to_s "L#@level: #{self.class.name.split('::')[-1]}\n#@txt" end |