search for: insert_delimiter_at

Displaying 1 result from an estimated 1 matches for "insert_delimiter_at".

2007 Apr 17
0
Helper help - inserting delimiters
My ruby skills are a bit underdeveloped, but I managed to whip up a Helper that inserts a delimiter at a fixed position in a number. Any wizards out there that can give tips on how to scale this to accepting calls for putting a delimiter at more than 1 position? def insert_delimiter_at(number, pos, delimiter="-") begin number = number.to_s parts = [] parts[0] = number.to(pos-1) parts[1] = number.from(pos) number = parts.join delimiter rescue number end end --~--~---------~--~----~------------~-------~--~----~ You recei...