Class: Optimus::Data::Row
- Inherits:
-
Object
- Object
- Optimus::Data::Row
- Defined in:
- lib/optimus_data.rb
Instance Attribute Summary collapse
-
#sort_value ⇒ Object
Returns the value of attribute sort_value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
- #columns ⇒ Object
-
#initialize(parent, data = [], sort_value = 1) ⇒ Row
constructor
A new instance of Row.
- #values ⇒ Object
- #values=(ar) ⇒ Object
Constructor Details
#initialize(parent, data = [], sort_value = 1) ⇒ Row
Returns a new instance of Row.
135 136 137 138 139 140 |
# File 'lib/optimus_data.rb', line 135 def initialize(parent, data = [], sort_value = 1) @parent = parent @data = data # Ensure it's comparable @sort_value = sort_value end |
Instance Attribute Details
#sort_value ⇒ Object
Returns the value of attribute sort_value.
133 134 135 |
# File 'lib/optimus_data.rb', line 133 def sort_value @sort_value end |
Instance Method Details
#<=>(other) ⇒ Object
158 159 160 |
# File 'lib/optimus_data.rb', line 158 def <=>(other) @sort_value <=> other.sort_value end |
#[](index) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/optimus_data.rb', line 142 def [](index) num_index = @parent.find_column_index(index) unless (num_index.is_a?(Fixnum) and @parent.columns.length>num_index) raise IndexError.new("Column #{index} does not exist") end return @data[num_index] end |
#[]=(index, value) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/optimus_data.rb', line 150 def []=(index, value) num_index = @parent.find_or_add_column_index(index) if num_index.nil? raise IndexError.new("Column #{num_index} does not exist") end @data[num_index] = value end |
#columns ⇒ Object
162 163 164 |
# File 'lib/optimus_data.rb', line 162 def columns @parent.columns end |
#values ⇒ Object
166 167 168 |
# File 'lib/optimus_data.rb', line 166 def values return @data end |
#values=(ar) ⇒ Object
170 171 172 |
# File 'lib/optimus_data.rb', line 170 def values=(ar) @data = ar end |