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:0x00000002ccf3b0 @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=>[[0, 1, 11, 11], [1, 2, 12, 22], [2, 3, 13, 33], [3, 4, 14, 44], [4, 5, 15, 55]]}, @user_options={}, @adapter=Daru::View::Adapter::DatatablesAdapter, @table=#<Daru::DataTables::DataTable:0x00000002ccf338 @html_options={:table_options=>{:class=>"display", :cellspacing=>"0", :width=>"100%"}}, @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=>[[0, 1, 11, 11], [1, 2, 12, 22], [2, 3, 13, 33], [3, 4, 14, 44], [4, 5, 15, 55]]}>>
In [5]:
dt_df.show_in_iruby
Out[5]:
a b c
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\t$('#table_id4').DataTable(\n\t\t{pageLength: 3, data: [[0,1,11,11],[1,2,12,22],[2,3,13,33],[3,4,14,44],[4,5,15,55]]}\n\t);\n\n});\n</script>\n<table class=\"display\" cellspacing=\"0\" width=\"100%\" id=\"table_id4\"><thead>\n  \n    <tr>\n      <th></th>\n      \n        <th>a</th>\n      \n        <th>b</th>\n      \n        <th>c</th>\n      \n    </tr>\n  \n</thead></table>"
In [7]:
IRuby.html html_code_dt_df
Out[7]:
a b c