K
Kyle Schmitt
I just had a funny thing happen.
I've got a bunch of classes that take a url for their initialize
methods, and do a little cleaning on the url, just in case.
I was setting them all up like this
@url = "http://localhost:1948/"
@one = pageOne(@url)
@two = pageTwo(@url)
@three = pageThree(@url)
Because of the housekeeping & pass-by-reference being standard, @url
ended up getting longer and longer, and strange and stranger.
I know a dozen fairly easy ways of solving this problem, but my
question is, what is the _right_ way to solve it in ruby?
I could easily do this in the SuperPage class that all the pages
inherit from, but it seems a tad awkward. Then again so do some of
the other ideas I have.
def initailize(url)
@url=cleanURL(url.clone)
end
Thanks,
Kyle
I've got a bunch of classes that take a url for their initialize
methods, and do a little cleaning on the url, just in case.
I was setting them all up like this
@url = "http://localhost:1948/"
@one = pageOne(@url)
@two = pageTwo(@url)
@three = pageThree(@url)
Because of the housekeeping & pass-by-reference being standard, @url
ended up getting longer and longer, and strange and stranger.
I know a dozen fairly easy ways of solving this problem, but my
question is, what is the _right_ way to solve it in ruby?
I could easily do this in the SuperPage class that all the pages
inherit from, but it seems a tad awkward. Then again so do some of
the other ideas I have.
def initailize(url)
@url=cleanURL(url.clone)
end
Thanks,
Kyle