Sha256: d4494d78933c3ca885be970f47d84c371c509fa6251b0254aa4cf43ac22f5dde

Contents?: true

Size: 598 Bytes

Versions: 5

Compression:

Stored size: 598 Bytes

Contents

# Adds the model methods to the data frame.
class DataFrame
  
  # Returns a model if defined
  # Defines a model with a block, if given and not defined
  # Stores the model in the models container, which gives us access like:
  # df.models.new_model_name...
  def model(name=nil, &block)
    return self.models[name] if self.models.table.keys.include?(name)
    return false unless block
    @pc = ParameterCapture.new(&block)
    model = self.filter(Hash) do |row|
      @pc.filter(row)
    end
    self.models.table[name] = model
  end
  
  def models
    @models ||= OpenStruct.new
  end
  
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
davidrichards-data_frame-0.0.17 lib/data_frame/model.rb
davidrichards-data_frame-0.0.18 lib/data_frame/model.rb
davidrichards-data_frame-0.0.19 lib/data_frame/model.rb
davidrichards-data_frame-0.0.20 lib/data_frame/model.rb
data_frame-0.1.8 lib/data_frame/model.rb