Module: Csv2hash::Discover
- Included in:
- Validator
- Defined in:
- lib/csv2hash/discover.rb
Instance Method Summary collapse
Instance Method Details
#find_dynamic_position(cell) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/csv2hash/discover.rb', line 4 def find_dynamic_position cell y, x = cell.rules.fetch :position column, matcher = y dynamic_y_axe = data_source.index { |entries| entries[column] =~ matcher } if dynamic_y_axe.nil? if cell.rules.fetch(:allow_blank) return nil else raise "Y doesn't found for #{cell.rules[:position]} on :#{cell.rules.fetch(:key)}" end else cell.rules[:position] = [dynamic_y_axe, x] cell end end |