tags:

views:

33

answers:

2
A: 

You can do this with gsub string method and regular expresions

doc = open("myfile.html") { |f| 
  f.read().gsub(/<img src="([^"]*)".*\/>/, '<%= image_tag("\1") %>') 
}

I don't have hpricot installed but it seems (check this hpricot-altering) that you coud use swap method on searched elements

imgs.each { |i|
  i.swap('<%= image_tag(' + i.src + ') %>')
}
jcubic
A: 
Alex