replace system call with ruby method

The rationale behind this: ruby method feels natural than shelling out.