class Mikon::Row

Row class for internal use

Attributes

arr[R]
index[R]
labels[R]

Public Class Methods

new(labels, arr, index) click to toggle source
# File lib/mikon/core/dataframe.rb, line 371
def initialize(labels, arr, index)
  @labels = labels
  @arr = arr
  @index = index
end

Public Instance Methods

[](name) click to toggle source
# File lib/mikon/core/dataframe.rb, line 377
def [](name)
  pos = @labels.index(name)
  pos.nil? ? nil : @arr[pos]
end
[]=(name, val) click to toggle source
# File lib/mikon/core/dataframe.rb, line 382
def []=(name, val)
  pos = @labels.index(name)
  if pos.nil?
    @labels.push(name)
    @arr.push(val)
  else
    @arr[pos] = val
  end
end
method_missing(name, *args) click to toggle source

@example

row = Row.new([:a, :b, :c], [1, 2, 3], :example_row)
puts row.instance_eval { a * b * c} #-> 7
Calls superclass method
# File lib/mikon/core/dataframe.rb, line 395
def method_missing(name, *args)
  super unless args.length == 0
  pos = @labels.index(name)
  pos.nil? ? super : @arr[pos]
end
to_hash() click to toggle source
# File lib/mikon/core/dataframe.rb, line 401
def to_hash
  @labels.each.with_index.reduce({}) do |memo, (label, i)|
    memo[label] = @arr[i]
    memo
  end
end