Sha256: 7ad5fd3755515502ddecd40b45486ec7c05cff4665ed0a4b6b4eeb944f8a94fb

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require_relative "object_table/version"
require_relative "object_table/basic_grid"
require_relative "object_table/table_methods"
require_relative "object_table/view"
require_relative "object_table/static_view"
require_relative "object_table/column"
require_relative "object_table/stacking"
require_relative "object_table/factory"
require_relative "object_table/joining"

class ObjectTable
  include TableMethods
  include Stacking::InPlace
  include Factory

  extend Stacking::ClassMethods
  extend Joining::ClassMethods

  attr_reader :columns

  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

  def add_column(name, typecode='object', *args)
    col = NArray.new(typecode, *args, nrows)
    columns[name] = col
  end

  def sort_by!(*keys)
    sort_index = _get_sort_index(keys)

    columns.each do |k, v|
      columns[k] = v[sort_index]
    end
    self
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
object_table-0.4.1 lib/object_table.rb
object_table-0.4.0 lib/object_table.rb