Class: ObjectTable
- Inherits:
-
Object
- Object
- ObjectTable
- Extended by:
- Joining::ClassMethods, Stacking::ClassMethods
- Includes:
- Factory, Stacking::InPlace, TableMethods
- Defined in:
- lib/object_table.rb,
lib/object_table/joining.rb,
lib/object_table/version.rb,
lib/object_table/grouping.rb,
lib/object_table/printing.rb,
lib/object_table/stacking.rb
Defined Under Namespace
Modules: Column, Factory, Joining, Printing, Stacking, TableMethods, Util, ViewMethods Classes: BasicGrid, Group, Grouping, MaskedColumn, StaticView, View
Constant Summary collapse
- VERSION =
"0.4.0"
Constants included from Factory
Factory::CLASS_MAP, Factory::FACTORIES
Constants included from TableMethods
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
Attributes included from TableMethods
Instance Method Summary collapse
- #add_column(name, typecode = 'object', *args) ⇒ Object
-
#initialize(columns = {}) ⇒ ObjectTable
constructor
A new instance of ObjectTable.
- #sort_by!(*keys) ⇒ Object
Methods included from Stacking::ClassMethods
Methods included from Joining::ClassMethods
Methods included from Factory
Methods included from Stacking::InPlace
Methods included from TableMethods
#==, #_get_sort_index, #apply, #clone, #each_row, #group_by, #method_missing, #ncols, #nrows, #respond_to?, #set_column, #sort_by, #where
Methods included from Stacking
process_stackable_grid, #stack, stack_segments
Methods included from Joining
Methods included from Printing
calc_column_widths, format_column, format_rows, format_section, #inspect, split_column_lines
Constructor Details
#initialize(columns = {}) ⇒ ObjectTable
Returns a new instance of ObjectTable.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/object_table.rb', line 21 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.
19 20 21 |
# File 'lib/object_table.rb', line 19 def columns @columns end |
Instance Method Details
#add_column(name, typecode = 'object', *args) ⇒ Object
35 36 37 38 |
# File 'lib/object_table.rb', line 35 def add_column(name, typecode='object', *args) col = NArray.new(typecode, *args, nrows) columns[name] = col end |
#sort_by!(*keys) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/object_table.rb', line 40 def sort_by!(*keys) sort_index = _get_sort_index(keys) columns.each do |k, v| columns[k] = v[sort_index] end self end |