Class: DataView::DataView::Row

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/data_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_view, values = {}) ⇒ Row

Returns a new instance of Row.



9
10
11
12
# File 'lib/data_view.rb', line 9

def initialize(data_view, values = {})
	@data_view = data_view
	@values = values
end

Instance Attribute Details

#data_viewObject

Returns the value of attribute data_view.



8
9
10
# File 'lib/data_view.rb', line 8

def data_view
  @data_view
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/data_view.rb', line 13

def [](key)
	return @values[get_key(key)]
end

#[]=(key, value) ⇒ Object



16
17
18
# File 'lib/data_view.rb', line 16

def []=(key, value)
	@values[get_key(key)] = value
end

#eachObject



19
20
21
22
23
# File 'lib/data_view.rb', line 19

def each
	data_view.columns.each_with_index do |c, i|
		yield(c, @values[c])
	end
end

#lengthObject



24
25
26
# File 'lib/data_view.rb', line 24

def length
	@values.length
end