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.
210 211 212 |
# File 'lib/docgenerator.rb', line 210 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.
171 172 173 174 175 |
# File 'lib/docgenerator.rb', line 171 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.
201 202 203 204 205 |
# File 'lib/docgenerator.rb', line 201 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.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/docgenerator.rb', line 124 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.
181 182 183 184 185 |
# File 'lib/docgenerator.rb', line 181 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.
161 162 163 164 165 |
# File 'lib/docgenerator.rb', line 161 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.
151 152 153 154 155 |
# File 'lib/docgenerator.rb', line 151 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.
191 192 193 194 195 |
# File 'lib/docgenerator.rb', line 191 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 |