正規表現の専門家ではないので、次のコードは最適化できると思います。助けていただければ幸いです。
line = ".ui-icon-arrowrefresh-1-s { background-position: -176px -3px; }"
line.gsub!(/-?\d+px/) do |match|
match.gsub(/-?\d+/) do |i|
i.to_i + 4
end
end
#=> ".ui-icon-arrowrefresh-1-s { background-position: -172px 1px; }"