Method options are better if you ever want to extend it. I personally
would have both in library code, but would be inclined to keep the
multiple method code private to keep the interface clean.
class String
private
def align(direction. spacing)
case direction
when :left
...
when :right
...
when :center
...
end
end
public
def align_left(spacing)
align(:left,spacing)
end
def align_right(spacing)
align(:right,spacing)
end
def align_center(spacing)
align(:center,spacing)
end
end
--
Posted via http://www.ruby-forum.com/.