[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

dynamically read object's attributes

mark.pelletier

9/21/2007 3:13:00 PM

I want to read the values of instance variables in an object, but I
don't know how to reach them. I think the code should be something
like:

def read_stuff
s = "Class: #{self.class}:\n"
s += "Instance variables:\n"
self.instance_variables.each do
|var|
s += "#{var}: #{SOMETHING}\n"
end
s += "\n"
end

But I don't know what to replace SOMETHING with. Anyone know?
--
Posted via http://www.ruby-....

15 Answers

Stefano Crocco

9/21/2007 3:16:00 PM

0

Alle venerdì 21 settembre 2007, Mark Pelletier ha scritto:
> I want to read the values of instance variables in an object, but I
> don't know how to reach them. I think the code should be something
> like:
>
> def read_stuff
> s = "Class: #{self.class}:\n"
> s += "Instance variables:\n"
> self.instance_variables.each do
>
> |var|
>
> s += "#{var}: #{SOMETHING}\n"
> end
> s += "\n"
> end
>
> But I don't know what to replace SOMETHING with. Anyone know?

instance_variable_get var

Stefano

Tim Hunter

9/21/2007 3:18:00 PM

0

Mark Pelletier wrote:
> I want to read the values of instance variables in an object, but I
> don't know how to reach them. I think the code should be something
> like:
>
> def read_stuff
> s = "Class: #{self.class}:\n"
> s += "Instance variables:\n"
> self.instance_variables.each do
> |var|
> s += "#{var}: #{SOMETHING}\n"
> end
> s += "\n"
> end
>
> But I don't know what to replace SOMETHING with. Anyone know?

Object#instance_variable_get
--
Posted via http://www.ruby-....

mark.pelletier

9/21/2007 3:20:00 PM

0

Thanks to both of you.

Mark

Stefano Crocco wrote:
> Alle venerdì 21 settembre 2007, Mark Pelletier ha scritto:
>>
>> s += "#{var}: #{SOMETHING}\n"
>> end
>> s += "\n"
>> end
>>
>> But I don't know what to replace SOMETHING with. Anyone know?
>
> instance_variable_get var
>
> Stefano

--
Posted via http://www.ruby-....

Jano Svitok

9/21/2007 3:22:00 PM

0

On 9/21/07, Mark Pelletier <mark.pelletier@asrcms.com> wrote:
> I want to read the values of instance variables in an object, but I
> don't know how to reach them. I think the code should be something
> like:
>
> def read_stuff
> s = "Class: #{self.class}:\n"
> s += "Instance variables:\n"
> self.instance_variables.each do
> |var|
> s += "#{var}: #{SOMETHING}\n"
> end
> s += "\n"
> end
>
> But I don't know what to replace SOMETHING with. Anyone know?

instance_variable_get(var)

You might want to read rdoc for Object and Module for more similar
interesting methods.

PolishKnight

2/5/2011 3:07:00 PM

0

In article <eC63p.41442$3K.39057@newsfe12.iad>,
"Society" <Society@feminism.is.invalid> wrote:

> "Mitchell Holman" <nomail@comcast.net> wrote in message
> news:Xns9E814B4E6A257nomailcomcastnet@216.196.121.131...
> >
> > "J" <jvisions@live.com> wrote in news:4ea6e5.7p0.19.1@news.alt.net:
> >>
> >> BASIC "female" skills are becoming endangered> >> with fewer young women able to iron a shirt,
> >> cook a roast chicken or hem a skirt.
> >
> > How about the men?
>
> They are held to much higher standards, of course.
>
> > How many Gen Y guys can handle the "male" skills
> > of changing a tire,
>
> It was "iron a shirt," not "sew a shirt."
>
> The correct comparison "to iron a shirt" would be
> "to inflate a tire."
>
> > hunting, dressing out wild game,
>
> Ha ha. Maybe your eyes read "raise and butcher a chicken"
> instead of "roast a chicken," eh? The correct comparison
> to "roast a chicken" is "barbecue a chicken."
>
> > fixing a leaky faucet?
>
> Again, you hold men to a higher standard. (Well,
> that's the result of going on 50 years of feminism!)
> Look again. It's "hem a skirt" we're comparing,
> not "reconstruct a skirt."

Indeed, Society, this very comparison illustrates something I observed
about a critical flaw of double-dipper feminine thinking 20 years ago.

The various traditional male skills above illustrate a
protector/provider role. It doesn't matter whether the man changes the
tire or pays someone else to do it out of money he earned. The key is
that he gets those jobs done.

On the other hand, what does a career women do that's feminine? Is
paying someone else (often a below market wage) to look after her kids
or clean the house as feminine as doing those things herself?
Especially when the money just comes out of a joint account the man
contributes to?

In addition, what feminists and female supremecists jumped on was the
"personal touch". A woman got alimony and child-support because it was
"special" when mommy did them and got the credit or payment. Otherwise,
the maid and nanny are the "primary parents."

Remember the line from the AT&T commercial I teased Parg with?

"Mommy? When can I be a client?"

regards,
PolishKnight

Mitchell Holman

2/5/2011 4:32:00 PM

0

PolishKnight <marek1965@comcast.net> wrote in news:marek1965-
83BA75.10063005022011@news.giganews.com:

> In article <eC63p.41442$3K.39057@newsfe12.iad>,
> "Society" <Society@feminism.is.invalid> wrote:
>
>> "Mitchell Holman" <nomail@comcast.net> wrote in message
>> news:Xns9E814B4E6A257nomailcomcastnet@216.196.121.131...
>> >
>> > "J" <jvisions@live.com> wrote in news:4ea6e5.7p0.19.1@news.alt.net:
>> >>
>> >> BASIC "female" skills are becoming endangered>> >> with fewer young women able to iron a shirt,
>> >> cook a roast chicken or hem a skirt.
>> >
>> > How about the men?
>>
>> They are held to much higher standards, of course.
>>
>> > How many Gen Y guys can handle the "male" skills
>> > of changing a tire,
>>
>> It was "iron a shirt," not "sew a shirt."
>>
>> The correct comparison "to iron a shirt" would be
>> "to inflate a tire."
>>
>> > hunting, dressing out wild game,
>>
>> Ha ha. Maybe your eyes read "raise and butcher a chicken"
>> instead of "roast a chicken," eh? The correct comparison
>> to "roast a chicken" is "barbecue a chicken."
>>
>> > fixing a leaky faucet?
>>
>> Again, you hold men to a higher standard. (Well,
>> that's the result of going on 50 years of feminism!)
>> Look again. It's "hem a skirt" we're comparing,
>> not "reconstruct a skirt."
>
> Indeed, Society, this very comparison illustrates something I observed
> about a critical flaw of double-dipper feminine thinking 20 years ago.
>
> The various traditional male skills above illustrate a
> protector/provider role. It doesn't matter whether the man changes the
> tire or pays someone else to do it out of money he earned. The key is
> that he gets those jobs done.
>
> On the other hand, what does a career women do that's feminine? Is
> paying someone else (often a below market wage) to look after her kids
> or clean the house as feminine as doing those things herself?
> Especially when the money just comes out of a joint account the man
> contributes to?


What is "masculine" about paying a tow truck driver
or "feminine" about paying a nanny?

>
> In addition, what feminists and female supremecists jumped on was the
> "personal touch". A woman got alimony and child-support because it was
> "special" when mommy did them and got the credit or payment.
Otherwise,
> the maid and nanny are the "primary parents."


You need to update your prejudice. There has been a sharp
rise in the number of women PAYING child support. And putting
their careers ahead of parenting, and giving up custody in
the process, as men have done for years. Child support payments
are not about feminism, they are about child support.

http://tinyurl.c...
http://tinyurl.c...













PolishKnight

2/5/2011 9:06:00 PM

0

In article <Xns9E836B7179886nomailcomcastnet@216.196.121.131>,
Mitchell Holman <nomail@comcast.net> wrote:

> PolishKnight <marek1965@comcast.net> wrote in news:marek1965-
> 83BA75.10063005022011@news.giganews.com:
>
> > In article <eC63p.41442$3K.39057@newsfe12.iad>,
> > "Society" <Society@feminism.is.invalid> wrote:
> >
> >> "Mitchell Holman" <nomail@comcast.net> wrote in message
> >> news:Xns9E814B4E6A257nomailcomcastnet@216.196.121.131...
> >> >
> >> > "J" <jvisions@live.com> wrote in news:4ea6e5.7p0.19.1@news.alt.net:
> >> >>
> >> >> BASIC "female" skills are becoming endangered> >> >> with fewer young women able to iron a shirt,
> >> >> cook a roast chicken or hem a skirt.
> >> >
> >> > How about the men?
> >>
> >> They are held to much higher standards, of course.
> >>
> >> > How many Gen Y guys can handle the "male" skills
> >> > of changing a tire,
> >>
> >> It was "iron a shirt," not "sew a shirt."
> >>
> >> The correct comparison "to iron a shirt" would be
> >> "to inflate a tire."
> >>
> >> > hunting, dressing out wild game,
> >>
> >> Ha ha. Maybe your eyes read "raise and butcher a chicken"
> >> instead of "roast a chicken," eh? The correct comparison
> >> to "roast a chicken" is "barbecue a chicken."
> >>
> >> > fixing a leaky faucet?
> >>
> >> Again, you hold men to a higher standard. (Well,
> >> that's the result of going on 50 years of feminism!)
> >> Look again. It's "hem a skirt" we're comparing,
> >> not "reconstruct a skirt."
> >
> > Indeed, Society, this very comparison illustrates something I observed
> > about a critical flaw of double-dipper feminine thinking 20 years ago.
> >
> > The various traditional male skills above illustrate a
> > protector/provider role. It doesn't matter whether the man changes the
> > tire or pays someone else to do it out of money he earned. The key is
> > that he gets those jobs done.
> >
> > On the other hand, what does a career women do that's feminine? Is
> > paying someone else (often a below market wage) to look after her kids
> > or clean the house as feminine as doing those things herself?
> > Especially when the money just comes out of a joint account the man
> > contributes to?
>
>
> What is "masculine" about paying a tow truck driver
> or "feminine" about paying a nanny?

I explain below (sheesh, can't people wait to finish reading a
paragraph?)

> > In addition, what feminists and female supremecists jumped on was the
> > "personal touch". A woman got alimony and child-support because it was
> > "special" when mommy did them and got the credit or payment.
> Otherwise,
> > the maid and nanny are the "primary parents."
>
>
> You need to update your prejudice. There has been a sharp
> rise in the number of women PAYING child support.

Indeed. So many women are neglecting their children that the even
courts biased in the favor of motherhood has to give custody to men.
Consider Brittany Spears. :-)

In addition, women default at a much higher rate in paying their "child"
support than men. FYI.

> And putting
> their careers ahead of parenting, and giving up custody in
> the process, as men have done for years.

I don't think that's what happens in regards to that statistic. I
suspect the women losing custody and winding up paying support is due to
substance abuse issues or extreme neglect or other issues that a court
can't openly ignore or sweep under the rug.

> Child support payments
> are not about feminism, they are about child support.
>
> http://tinyurl.c...
> http://tinyurl.c...

In the second URL, a woman just dumped her children on her ex so she
could pursue a law career but no mention of her paying "child" support.
Indeed, many men who do get custody under an agreement with their
ex-wife or girlfriend don't bother pursuing "child" support because it's
not about the money to them but the best interests of the children.

In the case of excessively high CS where the amount is set by the man's
income and the woman often refuses to go to work, it's just a form of
backdoor alimony. If she spend the "child" support money on herself,
then it's not "child" support.

regards,
PolishKnight

Society

2/7/2011 3:32:00 AM

0


"PolishKnight" <marek1965@comcast.net> wrote in message
news:marek1965-46CE87.16054505022011@news.giganews.com...
>
> Mitchell Holman <nomail@comcast.net> wrote:
>>
>> PolishKnight wrote...
>>>
>>> The various traditional male skills above illustrate
>>> a protector/provider role. It doesn't matter whether
>>> the man changes the tire or pays someone else to do it
>>> out of money he earned. The key is that he gets those
>>> jobs done.
>>
>> What is "masculine" about paying a tow truck driver
>> or "feminine" about paying a nanny?
>
> I explain below (sheesh, can't people wait to finish reading a
> paragraph?)

Feminists are often in a hurry to beclown themselves.
(Whether this is due to their nature or nurture, I leave
to the feminists to explain. ;-)

I'm amused to see Mitchell Holman, who is a frequent
excuse-maker for feminists, blunder into exposing
what a muddle feminists have made of their brains
by asking such a question. The question practically
answers itself yet Mitchell Holman is blind to the
obvious.

For the slow witted (read: feminists) among the
readers, I'll break it down:

Masculine role = "protector/provider"

Feminine role = child-rearing

To "pay" is to "provide." Thus, "paying a tow truck
driver" is masculine. "Paying a nanny" isn't feminine, btw.

Hey feminists, HTH.

--
All excuses for feminism depend on the stupidity
of their swallowers.


Mitchell Holman

2/7/2011 4:01:00 AM

0

"Society" <Society@feminism.is.invalid> wrote in news:RJJ3p.44261
$3K.21558@newsfe12.iad:

>
> "PolishKnight" <marek1965@comcast.net> wrote in message
> news:marek1965-46CE87.16054505022011@news.giganews.com...
>>
>> Mitchell Holman <nomail@comcast.net> wrote:
>>>
>>> PolishKnight wrote...
>>>>
>>>> The various traditional male skills above illustrate
>>>> a protector/provider role. It doesn't matter whether
>>>> the man changes the tire or pays someone else to do it
>>>> out of money he earned. The key is that he gets those
>>>> jobs done.
>>>
>>> What is "masculine" about paying a tow truck driver
>>> or "feminine" about paying a nanny?
>>
>> I explain below (sheesh, can't people wait to finish reading a
>> paragraph?)
>
> Feminists are often in a hurry to beclown themselves.
> (Whether this is due to their nature or nurture, I leave
> to the feminists to explain. ;-)
>
> I'm amused to see Mitchell Holman, who is a frequent
> excuse-maker for feminists, blunder into exposing
> what a muddle feminists have made of their brains
> by asking such a question. The question practically
> answers itself yet Mitchell Holman is blind to the
> obvious.
>
> For the slow witted (read: feminists) among the
> readers, I'll break it down:
>
> Masculine role = "protector/provider"


So George Clooney and Bruce Willis and Matt Dillon
and Vince Vaughn are not "masculine" because they are
single and not doing any "protecting/providing"?


>
> Feminine role = child-rearing


So Condi Rice and Julia Roberts and Cameron Diaz
and Rene Zellwinger are not feminine because they
aren't mothers?


You are making even less sense than usual here....





Lady Veteran

2/7/2011 4:26:00 AM

0

On Sun, 6 Feb 2011 19:32:14 -0800, "Society"
<Society@feminism.is.invalid> wrote:

>
>"PolishKnight" <marek1965@comcast.net> wrote in message
>news:marek1965-46CE87.16054505022011@news.giganews.com...
>>
>> Mitchell Holman <nomail@comcast.net> wrote:
>>>
>>> PolishKnight wrote...
>>>>
>>>> The various traditional male skills above illustrate
>>>> a protector/provider role. It doesn't matter whether
>>>> the man changes the tire or pays someone else to do it
>>>> out of money he earned. The key is that he gets those
>>>> jobs done.
>>>
>>> What is "masculine" about paying a tow truck driver
>>> or "feminine" about paying a nanny?
>>
>> I explain below (sheesh, can't people wait to finish reading a
>> paragraph?)
>
>Feminists are often in a hurry to beclown themselves.
>(Whether this is due to their nature or nurture, I leave
>to the feminists to explain. ;-)

I see you have never been in a situation where you were denied
promotions and respect due to you gender. It is high time you did.


>
>I'm amused to see Mitchell Holman, who is a frequent
>excuse-maker for feminists, blunder into exposing
>what a muddle feminists have made of their brains
>by asking such a question. The question practically
>answers itself yet Mitchell Holman is blind to the
>obvious.

You would say that everyone but those who thinks like you is blind to
the gospel you preach. I know your type.

People like you cannot face the idea that their mothers would have
wanted to do something other than watch you spit up, changing diapers
and the like.

You were not the type of child that made all women want to be mothers.
Far from it.

>
>For the slow witted (read: feminists) among the
>readers, I'll break it down:

See? If his mother were alive he would ask her if she wanted to be
anything other than a "housewife." She probably isn't though. He is an
old codger, after all.

>
>Masculine role = "protector/provider"

Maybe in 1865....

>
>Feminine role = child-rearing


Again, maybe in 1865...

>
>To "pay" is to "provide." Thus, "paying a tow truck
>driver" is masculine. "Paying a nanny" isn't feminine, btw.

You are so full of yourself. You are probably one of those dirty old
men that cannot imagine taking a woman seriously.

I am so very glad you are not in charge.

>
>Hey feminists, HTH.

Hey Polish Sausage.....FEH!!! Society Outcast is a day late and a
dollar short.



LV

--


"I rode a tank and held a general's rank
When the blitzkrieg raged and the bodies stank."

---Sympathy for the Devil-The Rolling Stones
--------------------------------------------
"Some people are only alive because it is
illegal to kill them."

---Anonymous
----------------------------------------------

"It's a sign of your own worth sometimes if you are
hated by the right people."

---Miles Franklin
----------------------------------------------

See the latest idiot featured on my blog!

My Blog http://ladyveteranslog.bl...
---------------------------------------------
Are you being harassed on Usenet and want to fight
back instead of leaving the net? Are you willing to
stand up to Internet bullies and stalkers?

Join my group http://groups.yahoo.com/gro...
----------------------------------------------