Ruby: what the hell does this code saying ????
- by wefwgeweg
i discovered this in a dark place one day...what the hell is it supposed to do ??
def spliceElement(newelement,dickwad)
dox = Nokogiri::HTML(newelement)
fuck = dox.xpath("//text()").to_a
fuck.each do |shit|
if shit.text.include? ": "
dickwad << shit.text.split(': ')[1].strip + "|"
else
if shit.text =~ /\s{1,}/ or shit.text =~ /\n{1,}/
puts "fuck"
else
dickwad << shit.text.squeeze(" ").strip + "|"
end
end
end
dickwad << "\n"
end
def extract(newdoc, newarray)
doc = Nokogiri::HTML(newdoc)
collection = Array.new
newarray.each do |dong|
newb = doc.xpath(dong).to_a
#puts doc.xpath(dong).text
collection << newb
end
dickwad = "";
if collection.length > 1
(0...collection.first.length).each do |i|
(0...collection.length).each do |j|
somefield = collection[j][i].to_s.gsub(/\s{2,}/,' ')
spliceElement(somefield, dickwad)
end
newrow = dickwad.chop + "\n"
return newrow.to_s
end
else
collection.first.each do |shit|
somefield = shit.to_s.gsub(/\s{2,}/,' ')
spliceElement(somefield, dickwad)
puts somefield + "\n\n"
#newrow = dickwad.chop + "\n"
#puts newrow
#return newrow.to_s
sleep 1
end
end