Class: Automaton::Latex
- Inherits:
-
Object
show all
- Defined in:
- lib/latex.rb
Overview
Latex representation of an Automaton
Defined Under Namespace
Classes: Final, Initial, State, Transition
Instance Method Summary
collapse
Constructor Details
#initialize(initial, finals, states, transitions) ⇒ Latex
11
12
13
14
15
16
|
# File 'lib/latex.rb', line 11
def initialize(initial, finals, states, transitions)
@initial = Initial.new(initial)
@finals = finals.map{|final| Final.new(final)}
@states = states.map{|state| State.new(*state.to_a)}
@transitions = transitions.map{|transition| Transition.new(*transition.to_a)}
end
|
Instance Method Details
#==(other) ⇒ Object
33
34
35
|
# File 'lib/latex.rb', line 33
def ==(other)
self.values == other.values
end
|
#render_pdf(file_path) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/latex.rb', line 18
def render_pdf(file_path)
target_path = File.expand_path(file_path)
our_path = File.expand_path(File.dirname(__FILE__))
ENV['TEXINPUTS'] = ".:#{our_path}/tex:"
template = File.read("#{our_path}/tex/template.tex")
doc = RTeX::Document.new(template, :processor => 'tex2pdf')
doc.to_pdf(binding) do |tempfile_path|
FileUtils.mv tempfile_path, target_path
end
end
|
#values ⇒ Object
29
30
31
|
# File 'lib/latex.rb', line 29
def values
[@initial, @finals, @states, @transitions]
end
|