Class: MetricFu::Record
- Inherits:
-
Object
show all
- Defined in:
- lib/base/record.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data, columns) ⇒ Record
Returns a new instance of Record.
6
7
8
9
|
# File 'lib/base/record.rb', line 6
def initialize(data, columns)
@data = data
@columns = columns
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/base/record.rb', line 11
def method_missing(name, *args, &block)
key = name.to_s
if @data.has_key?(key)
@data[key]
elsif @columns.member?(key)
nil
else
super(name, *args, &block)
end
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
4
5
6
|
# File 'lib/base/record.rb', line 4
def data
@data
end
|
Instance Method Details
#[](key) ⇒ Object
26
27
28
|
# File 'lib/base/record.rb', line 26
def [](key)
@data[key]
end
|
#[]=(key, value) ⇒ Object
22
23
24
|
# File 'lib/base/record.rb', line 22
def []=(key, value)
@data[key]=value
end
|
#attributes ⇒ Object
38
39
40
|
# File 'lib/base/record.rb', line 38
def attributes
@columns
end
|
#has_key?(key) ⇒ Boolean
34
35
36
|
# File 'lib/base/record.rb', line 34
def has_key?(key)
@data.has_key?(key)
end
|
#keys ⇒ Object
30
31
32
|
# File 'lib/base/record.rb', line 30
def keys
@data.keys
end
|