From: matt@... (matt neuburg) Date: 2006-10-12T15:10:28+09:00 Subject: Re: how would *YOU* write this?? phil.swenson@gmail.com wrote: > Could write a method to take the image name as an > input and return 3 params... > > def image_attributes (item, image_name) > height = XPath.first(item, image_name + "/Height Units").text > width = XPath.first(item, image_name + "/Width Units").text > url = XPath.first(item, image_name + "/URL").text > return height, width, url > end def image_attributes(item, image_name) ["/Height Units", "/Width Units", "/URL"].collect do |s| XPath.first(item, image_name + s).text end end > small_image_height, small_image_width, small_image_url = > image_attributes(item, "SmallImage") > medium_image_height, medium_image_width, medium_image_url = > image_attributes(item, "MediumImage") > large_image_height, large_image_width, large_image_url = > image_attributes(item, "LargeImage") ["small", "medium", "large"].each do |s| eval %{ $#{s}_image_height, $#{s}_image_width, $#{s}_image_url = image_attributes(item, "#{s.capitalize}Image") } end Sorry, I ended up creating globals, $small_image_height etc. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Tiger - http://www.takecontrolbooks.com/tiger-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com