Module: Docgenerator::Element_methods
- Included in:
- Packages::Struktex::Structogramm
- Defined in:
- lib/docgenerator.rb
Overview
Small include-module to define to_doc.
You may include this method instead of define a element class as a subclass of Element.
In addition you get dummy definitions for
- to_latex
- to_html
- to_context
- to_creole
- to_wiki
- to_text
If you include this, please redefine this methods
Instance Method Summary collapse
-
#set_option_defaults(options) ⇒ Object
Instance-version of class method.
-
#to_context(options = {}) ⇒ Object
Dummy method.
-
#to_creole(options = {}) ⇒ Object
Dummy method.
-
#to_doc(target, options = {}) ⇒ Object
to_doc returns the object as a string.
-
#to_html(options = {}) ⇒ Object
Dummy method.
-
#to_latex(options = {}) ⇒ Object
Dummy method.
-
#to_text(options = {}) ⇒ Object
Dummy method.
-
#to_wiki(options = {}) ⇒ Object
Dummy method.
Instance Method Details
#set_option_defaults(options) ⇒ Object
Instance-version of class method.
214 215 216 |
# File 'lib/docgenerator.rb', line 214 def set_option_defaults() Docgenerator.set_option_defaults(, self) end |
#to_context(options = {}) ⇒ Object
Dummy method. Returns to_str (or to_s) and throws a log-information.
This method should be redefinded by subclasses.
175 176 177 178 179 |
# File 'lib/docgenerator.rb', line 175 def to_context( = {}) o = set_option_defaults() o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal? self.respond_to?(:to_str) ? self.to_str : self.to_s end |
#to_creole(options = {}) ⇒ Object
Dummy method. Returns to_str (or to_s) and throws a log-information.
This method should be redefinded by subclasses.
205 206 207 208 209 |
# File 'lib/docgenerator.rb', line 205 def to_creole( = {}) o = set_option_defaults() o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal? self.respond_to?(:to_str) ? self.to_str : self.to_s end |
#to_doc(target, options = {}) ⇒ Object
to_doc returns the object as a string.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/docgenerator.rb', line 128 def to_doc(target, = {}) o = set_option_defaults() str = "" case target when :latex str = self.to_latex() when :html str = self.to_html() when :context str = self.to_context() when :wiki str = self.to_wiki() when :creole str = self.to_creole() when :text str = self.to_text() else; o[:log].error( "Unknown target #{target.inspect} for #{self.class}") if o[:log].error? str = self.to_doc_str() end #case target str end |
#to_html(options = {}) ⇒ Object
Dummy method. Returns to_str (or to_s) and throws a log-information.
This method should be redefinded by subclasses.
185 186 187 188 189 |
# File 'lib/docgenerator.rb', line 185 def to_html( = {}) o = set_option_defaults() o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal? self.respond_to?(:to_str) ? self.to_str : self.to_s end |
#to_latex(options = {}) ⇒ Object
Dummy method. Returns to_str (or to_s) and throws a log-information.
This method should be redefinded by subclasses.
165 166 167 168 169 |
# File 'lib/docgenerator.rb', line 165 def to_latex( = {}) o = set_option_defaults() o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal? self.respond_to?(:to_str) ? self.to_str : self.to_s end |
#to_text(options = {}) ⇒ Object
Dummy method. Returns to_str (or to_s) and throws a log-information.
This method should be redefinded by subclasses.
155 156 157 158 159 |
# File 'lib/docgenerator.rb', line 155 def to_text( = {}) o = set_option_defaults() o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal? self.respond_to?(:to_str) ? self.to_str : self.to_s end |
#to_wiki(options = {}) ⇒ Object
Dummy method. Returns to_str (or to_s) and throws a log-information.
This method should be redefinded by subclasses.
195 196 197 198 199 |
# File 'lib/docgenerator.rb', line 195 def to_wiki( = {}) o = set_option_defaults() o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal? self.respond_to?(:to_str) ? self.to_str : self.to_s end |