Class: HTML_Table
Direct Known Subclasses
HTML_Table_of_Peak_Picking_Log, HTML_Table_of_Property_Differences
Instance Method Summary collapse
-
#initialize(arrData, opts = {}) ⇒ HTML_Table
constructor
A new instance of HTML_Table.
- #render ⇒ Object
- #save(file) ⇒ Object
Constructor Details
#initialize(arrData, opts = {}) ⇒ HTML_Table
Returns a new instance of HTML_Table.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/html_table.rb', line 8 def initialize(arrData,opts={}) @sort_code = if opts[:hashSort].nil? '' else #"data.sort([{column: 1, desc:true}]);" "data.sort([{column: #{opts[:hashSort][:col_number]}, desc:#{opts[:hashSort][:descending]}}]);" end @format_code = if opts[:hashFormat].nil? '' else #"var formatter = new google.visualization.BarFormat({width: 60}); formatter.format(data, 1);" "var formatter = new google.visualization.#{opts[:hashFormat][:type]}({width: 60}); formatter.format(data, #{opts[:hashFormat][:column]});" end @arrData = arrData @template = get_template @div = UUIDTools::UUID.random_create end |
Instance Method Details
#render ⇒ Object
32 33 34 35 36 |
# File 'lib/html_table.rb', line 32 def render unless @template.nil? || @arrData.nil? ERB.new(@template).result(binding) end end |
#save(file) ⇒ Object
38 39 40 41 42 |
# File 'lib/html_table.rb', line 38 def save(file) File.open(file, "w+") do |f| f.write(render) end end |