# How to merge multiple Variables (Hpricot::Elements)

**URL:** <https://www.ruby-forum.com/t/how-to-merge-multiple-variables-hpricot-elements/159754>\
**Category:** Ruby\
**Created:** [February 8, 2009, 12:03pm UTC](https://www.ruby-forum.com/t/how-to-merge-multiple-variables-hpricot-elements/159754 "2009-02-08T12:03:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [February 8, 2009, 12:03pm UTC](https://www.ruby-forum.com/t/how-to-merge-multiple-variables-hpricot-elements/159754/1 "2009-02-08T12:03:21Z")

</div>

Hey List,

i hpricot a website (Html Table) and want to normalize the data  
For now i have about five variables with all the data of one column.

e.g:  
(HTML Source)  
col1 :: col2 :: col3  
data1a :: data2a :: data3a  
data1b :: data2b :: data3b  
data1c :: data2c :: data3c

each column is hold in on variable (@col1data, @col2data…), and i have  
a while loop to “merge” the data to a new model:

eg:

while @col1data.size…

model = Model.new  
model.col1 = @col1data.shift.inner\_text  
model.col2 = @col2data.shift  
…

end

So i get three Models with the expected data.

But this is so damn ugly 😉

How can this be done without shift?

Thanks for your time!
