Class: ObjectTable
- Inherits:
-
Object
- Object
- ObjectTable
- Includes:
- Stacker, TableMethods
- Defined in:
- lib/object_table.rb,
lib/object_table/version.rb
Defined Under Namespace
Modules: Column, Printable, Stacker, TableChild, TableMethods, ViewMethods Classes: BasicGrid, Group, Grouped, MaskedColumn, StaticView, View
Constant Summary collapse
- VERSION =
"0.3.2"
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
Attributes included from TableMethods
Instance Method Summary collapse
- #__group_cls__ ⇒ Object
- #__static_view_cls__ ⇒ Object
- #__table_cls__ ⇒ Object
- #__view_cls__ ⇒ Object
- #add_column(name, typecode = 'object', *args) ⇒ Object
-
#initialize(columns = {}) ⇒ ObjectTable
constructor
A new instance of ObjectTable.
- #sort_by!(*keys) ⇒ Object
Methods included from Stacker
Methods included from TableMethods
#==, #_apply_block, #_get_sort_index, #apply, #clone, #colnames, #group_by, #method_missing, #ncols, #nrows, #pop_column, #respond_to?, #set_column, #sort_by, #where
Methods included from Printable
#_format_rows, #_format_section, calc_column_widths, get_printable_column, #inspect
Constructor Details
#initialize(columns = {}) ⇒ ObjectTable
Returns a new instance of ObjectTable.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/object_table.rb', line 16 def initialize(columns = {}) super() unless columns.is_a? BasicGrid columns = BasicGrid[columns] end columns._ensure_uniform_columns! @columns = columns @columns.each do |k, v| @columns[k] = NArray.to_na(v) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ObjectTable::TableMethods
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
14 15 16 |
# File 'lib/object_table.rb', line 14 def columns @columns end |
Instance Method Details
#__group_cls__ ⇒ Object
52 53 54 |
# File 'lib/object_table.rb', line 52 def __group_cls__ self.class::Group end |
#__static_view_cls__ ⇒ Object
44 45 46 |
# File 'lib/object_table.rb', line 44 def __static_view_cls__ self.class::StaticView end |
#__table_cls__ ⇒ Object
56 57 58 |
# File 'lib/object_table.rb', line 56 def __table_cls__ self.class end |
#__view_cls__ ⇒ Object
48 49 50 |
# File 'lib/object_table.rb', line 48 def __view_cls__ self.class::View end |
#add_column(name, typecode = 'object', *args) ⇒ Object
30 31 32 33 |
# File 'lib/object_table.rb', line 30 def add_column(name, typecode='object', *args) col = NArray.new(typecode, *args, nrows) columns[name] = col end |
#sort_by!(*keys) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/object_table.rb', line 35 def sort_by!(*keys) sort_index = _get_sort_index(keys) columns.each do |k, v| columns[k] = v[sort_index] end self end |