Extract IP from a list of NIC

I am looking to extract one IP out of four IPs assigned to a server.

Example: I have many servers with 4 ethernet cards per host and assigned to the NICs. I am able to pull IP addresses assigned to specific NIC using

eth0 is <%= node[:network][:interfaces][:eth0][:addresses].detect{|k,v| v[:family] == “inet” }.first %>

It was easier to pull addresses if the addresses were assigned in an order - like eth0 =, eth1 = etc. However in this case, the IPs are not assigned in an order and I am stuck with extracting the IP of my choice.

Could someone please help.