Does this give the desired output that you are after?

Just some quick irb says this might work, but I am not sure what you are after:

require 'facter'
Facter.value('interfaces').split(',').collect {|i| Facter.value("ipaddress_#{i}") }.select {|i| i }.join(',')