Permalink
Browse files

Added ability for table definition to be specified.

  • Loading branch information...
1 parent aa2314f commit c4c359222d6af9e510d4b9f84745ac89d455f90f @mikexstudios committed Mar 14, 2012
Showing with 13 additions and 2 deletions.
  1. +12 −1 tafel_plot2/fit_table.rb
  2. +1 −1 tafel_plot2/fit_template.erb
View
13 tafel_plot2/fit_table.rb 100644 → 100755
@@ -1,20 +1,23 @@
+#!/usr/bin/env ruby
require 'erb'
require 'csv'
class FitTable
attr_accessor :input, :output
- attr_accessor :title
+ attr_accessor :title, :definition
def initialize
template_path = File.join(File.dirname(__FILE__), "fit_template.erb")
@template = ERB.new(File.read(template_path), 0, trim_mode = '>')
@title = nil
+ @definition = 'lrlllr'
end
def make
#Open the CSV file, get data
csv = CSV.read(@input)
+ definition = @definition
#The first row is the header
header = csv.shift
#The rest is the data
@@ -33,3 +36,11 @@ def fit_table
yield FitTable.new
end
+if __FILE__ == $0
+ ft = FitTable.new
+ ft.input = ARGV[0]
+ ft.output = ARGV[1]
+ ft.title = ''
+
+ ft.make
+end
View
2 tafel_plot2/fit_template.erb
@@ -10,7 +10,7 @@
\begin{table}
\begin{center}
-\begin{tabular}{lrlllr}
+\begin{tabular}{<%= definition %>}
\toprule
<% header.each do |val| %>
\textbf{<%= val %>} <%= "&" unless val == header.last %>

0 comments on commit c4c3592

Please sign in to comment.