Robert, Todd, et. al.,
I apologize if my first post was missing some of the larger context, I
didn't want to have to give too much information about the problem
domain lest that deter replies ;).
The code I'm working on is used for storing Strings which contain
conjugations of Latin verbs ( I mean, people who lived near the
Mediterranean, not people south of the Rio Grande ).
Classical Latin words contain macrons on certain vowels ( the long bar
that signifies a "long" sound ). When following conjugation rules
occasionally the "macron-ized" character needs to be "shortened" and
the macron thus removed. Thus, for example "they love" is the stem of
the infinitive remove_ending("am\={a}re") + "nt" (I'm using LaTeX
style macron representation).
The rules dictate that you should chop off the "re" and add the "nt",
thus giving you "am\={a}nt".
BUT here's the rule, a macronized vowel before 'nt' or 'nd' anywhere
in the string must be shortened, thus the word is *actually* "amant".
There are other conditions that shorten a macron (comes before another
vowel, etc.).
Here's the output (at top) and code (at bottom): http://stevengharms.com/?page_id=1159
While I have the code that produces the "right" output, I'm trying to
refactor the code to be more Ruby-like, cleaner, and more organized.
So the code that I link to here is still functional, but not final
draft!
As it is currently, you enter a verb characterization from the CLI, a
Verb.new object is created with that string as the input. Those
pieces are broken up and you have a Verb object. You can then issue:
demo_verb=Verb.new( verb characterization string )
puts demo_verb.active_present
In 'active_present" 6 strings are created and returned in an array.
Each of these strings are passed to a "check_macron" routine which
removes macrons where needed.
Point #1 ( Original Question, effectively)
My idea was "Well, what if *every* string, in the duration of this
program, knows to check_macron itself at time of assignment OR at time
of being used for output" -- my idea being to "smarten" up String so
that I didn't have to go around invoking check_macron all over the
place. Further, I wouldn't have to change my ( heavy! ) use of the
String assignment idioms ( heavily used ).
Point #2:
I was against the idea of subclassing String because, as i understand
it, my assignments would take the look of:
aLatinString = LatinString.new("something")
instead of the very short and pleasant:
aRegularString = "razzle"
Perhaps I am mistaken in this?
Well, so that's the full story, likely full of a lot of extra details,
but hopefully you will make it through and be able to guide me to more
Ruby like constructions!
Steven