Sha256: bad37b01c86b4cd48b6bd296de16b7fc0fd2fc4653b861fadb12dca6c29f43e9
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'forwardable' require_relative 'view_methods' require_relative 'masked_column' class ObjectTable::View include ObjectTable::ViewMethods extend Forwardable def_delegators :make_view, :apply def initialize(parent, &block) super() @parent = parent @filter = block end def_delegators :@parent, :has_column? def get_column(name) col = @parent.get_column(name) ObjectTable::MaskedColumn.mask(col, indices) if col end alias_method :[], :get_column def make_view __static_view_cls__.new @parent, indices end def clone __table_cls__.new(columns) end def inspect(*args) cache_columns{ super } rescue NoMethodError => e raise Exception.new(e) end def indices @indices or NArray.int(@parent.nrows).indgen![@parent.apply &@filter] end def cache_indices(&block) @indices = indices value = block.call() @indices = nil value end def columns @columns or super end def cache_columns(&block) @columns = columns value = block.call() @columns = nil value end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
object_table-0.2.4 | lib/object_table/view.rb |