Module: Yummi::RowExtractor
- Included in:
- Table
- Defined in:
- lib/yummi/row_extractor.rb
Instance Method Summary collapse
- #extract_row_from_array(row, row_index) ⇒ Object
- #extract_row_from_hash(row, row_index) ⇒ Object
- #extract_row_from_object(row, row_index) ⇒ Object
- #extract_row_from_range(row, row_index) ⇒ Object
Instance Method Details
#extract_row_from_array(row, row_index) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/yummi/row_extractor.rb', line 23 def extract_row_from_array(row, row_index) array = [] row.each_index do |column_index| obj = TableContext::new( :obj => IndexedData::new(@aliases, row), :row_index => row_index, :column_index => column_index, :value => row[column_index] ) array << obj end array end |
#extract_row_from_hash(row, row_index) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/yummi/row_extractor.rb', line 4 def extract_row_from_hash(row, row_index) array = [] @aliases.each_index do |column_index| key = @aliases[column_index] obj = TableContext::new( :obj => row, :row_index => row_index, :column_index => column_index, :value => (row[key.to_sym] or row[key.to_s]) ) array << obj end array end |
#extract_row_from_object(row, row_index) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/yummi/row_extractor.rb', line 37 def extract_row_from_object(row, row_index) array = [] @aliases.each_index do |column_index| obj = TableContext::new( :obj => row, :row_index => row_index, :column_index => column_index, :value => row.send(@aliases[column_index]) ) def obj.[] (index) obj.send(index) end array << obj end array end |
#extract_row_from_range(row, row_index) ⇒ Object
19 20 21 |
# File 'lib/yummi/row_extractor.rb', line 19 def extract_row_from_range(row, row_index) row.to_a end |