Class: Docgenerator::Creole::Rail::Rail_diagramm

Inherits:
Object
  • Object
show all
Defined in:
lib/docgenerator/creole/plugins/rail.rb

Overview

A Rail-diagramm

Constant Summary collapse

TEX_PACKAGE_RAIL =

Can be used in document header to load rail.sty

element(:usepackage,{ }, 'rail').cr
RAIL_ALIAS =

Some command to be added in document header. Allows the usage of some characters as terminals.

<<'RAIL_ALIAS'
\railalias{lbrace}{\{}
\railalias{rbrace}{\}}
\railalias{dollar}{\$}
\railalias{underscore}{\_}
\railalias{percent}{\%}
\railalias{at}{@}
\railalias{atat}{@@}
% \railalias{backslash}{\char"5C}
\railalias{backslash}{\ensuremath{\backslash}}
\railalias{lt}{\ensuremath{<}}
\railalias{le}{\ensuremath{<=}}
\railalias{gt}{\ensuremath{>}}
\railalias{ge}{\ensuremath{>=}}
\railalias{caret}{\ensuremath{\hat{}}}
\railalias{tildeeq}{\ensuremath{\sim=}}
\railalias{quote}{'}
\railalias{dquote}{"}%german: \dq
\railterm{quote,dquote}
\railterm{lbrace,rbrace,dollar,percent,backslash,underscore,at,atat}
\railterm{lt,le,gt,ge,caret,tildeeq}
RAIL_ALIAS

Instance Method Summary collapse

Constructor Details

#initialize(key, code = '') ⇒ Rail_diagramm

Create new Rail diagramm. Parameter: -key -rail-definition



138
139
140
141
# File 'lib/docgenerator/creole/plugins/rail.rb', line 138

def initialize( key, code = '' )
  @key  = key
  @code  = code
end

Instance Method Details

#<<(code) ⇒ Object

Implement << for Wikicollector



143
144
145
# File 'lib/docgenerator/creole/plugins/rail.rb', line 143

def << (code)
  @code << code
end

#to_doc(target, options = {}) ⇒ Object

to_latex



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/docgenerator/creole/plugins/rail.rb', line 165

def to_doc( target, options = {})
  case target
    when :latex 
      self.to_latex( options )
    else
      o = set_option_defaults(options)
      #~ o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
      o[:log].error("Rail-diagramm not supported for #{target}") if o[:log].error?
      ''
  end #case target
end

#to_latex(options = {}) ⇒ Object

Return LaTeX-environment rail Requires rail.sty and rail.exe to generate the figure.



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/docgenerator/creole/plugins/rail.rb', line 152

def to_latex(options = {})
  @code = @code.join if @code.respond_to?(:join) #if Array is given
  return <<-RAIL
%
% Define a rail-diagramm #{@key}
%
\\begin{rail}
#{@key} :
#{@code.chomp}
;
\\end{rail}
RAIL
end