In [1]:
require 'daru/view'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.

Install the mechanize gem version ~>2.7.5 for using mechanize functions.
Out[1]:
true
In [2]:
Daru::View.table_library = :datatables
Out[2]:
:datatables
In [3]:
df = Daru::DataFrame.new({b: [11,12,13,14,15], a: [1,2,3,4,5],
      c: [11,22,33,44,55]},
      order: [:a, :b, :c],
      index: [:one, :two, :three, :four, :five])
Out[3]:
Daru::DataFrame(5x3)
a b c
one 1 11 11
two 2 12 22
three 3 13 33
four 4 14 44
five 5 15 55
In [4]:
dt_df =  Daru::View::Table.new(df, pageLength: 3)
Out[4]:
#<Daru::View::Table:0x007fa9f6b7ba40 @data=#<Daru::DataFrame(5x3)>
           a     b     c
   one     1    11    11
   two     2    12    22
 three     3    13    33
  four     4    14    44
  five     5    15    55, @options={:pageLength=>3, :data=>[[1, 11, 11], [2, 12, 22], [3, 13, 33], [4, 14, 44], [5, 15, 55]]}, @adapter=Daru::View::Adapter::DatatablesAdapter, @table=#<DataTables::DataTable:0x007fa9f739aa00 @options={:pageLength=>3, :data=>[[1, 11, 11], [2, 12, 22], [3, 13, 33], [4, 14, 44], [5, 15, 55]]}>>
In [5]:
dt_df.table.to_html
Out[5]:
"\n<script type='text/javascript'>\n  \n$(document).ready(function() {\n\n  $('#debb91b2-1d7d-4c77-9594-6b946ed9ac12').DataTable(\n    {pageLength: 3, data: [[1,11,11],[2,12,22],[3,13,33],[4,14,44],[5,15,55]]}\n  );\n\n});\n</script>\n"
In [6]:
table_opts = {
      class: "display",
      cellspacing: "0",
      width: "50%",
      table_html: "
      <thead>
            <tr>
                <th>Num1 </th>
                <th>Num2 </th>
                <th>Num3 </th>
            </tr>
        </thead>"
      }
    options = {
        table_options: table_opts
    }
html_code_dt_df = dt_df.table.to_html(id='table_id4', options)
Out[6]:
"\n<script type='text/javascript'>\n  \n$(document).ready(function() {\n\n  $('#table_id4').DataTable(\n    {pageLength: 3, data: [[1,11,11],[2,12,22],[3,13,33],[4,14,44],[5,15,55]]}\n  );\n\n});\n</script>\n<table class=\"display\" cellspacing=\"0\" width=\"50%\" id=\"table_id4\">\n      <thead>\n            <tr>\n                <th>Num1 </th>\n                <th>Num2 </th>\n                <th>Num3 </th>\n            </tr>\n        </thead></table>"
In [7]:
IRuby.html html_code_dt_df
Out[7]:
Num1 Num2 Num3