R
Ralph Shnelvar
[Note: parts of this message were removed to make it a legal post.]
I'm still not "getting it."
Consider
- - -
class DirectoryString < String
def initialize(arg)
super arg
end
def convert_forward_slash_to_back_slash
self.gsub(/\//, "\\")
end
def convert_forward_slash_to_back_slash!
self.gsub!(/\//, "\\")
end
def remove_trailing_backslash_if_any
self.chomp("\\")
end
def remove_trailing_backslash_if_any!
self.chomp!("\\")
end
def append_trailing_backslash_if_needed
remove_trailing_backslash_if_any + "\\"
end
def append_trailing_backslash_if_needed!
# ??????? What do I do here ??????? ... The following is illegal
self = "Help!"
end
end
- - -
The only thing I can think of is converting from the standard IS_A (Inheritance) to a HAS_A (create a member variable).
If I do the latter, above, I will have to create a ton of simple "forwarding" messages.
What's the Ruby way of doing this sort of thing?
I'm still not "getting it."
Consider
- - -
class DirectoryString < String
def initialize(arg)
super arg
end
def convert_forward_slash_to_back_slash
self.gsub(/\//, "\\")
end
def convert_forward_slash_to_back_slash!
self.gsub!(/\//, "\\")
end
def remove_trailing_backslash_if_any
self.chomp("\\")
end
def remove_trailing_backslash_if_any!
self.chomp!("\\")
end
def append_trailing_backslash_if_needed
remove_trailing_backslash_if_any + "\\"
end
def append_trailing_backslash_if_needed!
# ??????? What do I do here ??????? ... The following is illegal
self = "Help!"
end
end
- - -
The only thing I can think of is converting from the standard IS_A (Inheritance) to a HAS_A (create a member variable).
If I do the latter, above, I will have to create a ton of simple "forwarding" messages.
What's the Ruby way of doing this sort of thing?