[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Converting a string to a class

Gregory Brown

2/22/2006 10:23:00 PM

On 2/22/06, Anthony DeRobertis <aderobertis@metrics.net> wrote:
> Take the following snippet:

why do string conversion?

You can pass constants around in ruby just fine.

D:\Documents and Settings\Administrator>irb
irb(main):001:0> a = String
=> String
irb(main):002:0> a.new
=> ""
irb(main):003:0>

also, to get at a constant within a class, you just do SomeClass::SomeConstant

D:\Documents and Settings\Administrator>irb
irb(main):001:0> class A
irb(main):002:1> B = "hi"
irb(main):003:1> end
=> "hi"
irb(main):004:0> A::B
=> "hi"


10 Answers

Anthony DeRobertis

2/23/2006 3:08:00 PM

0

James Gray

2/23/2006 3:59:00 PM

0

On Feb 23, 2006, at 9:07 AM, Anthony DeRobertis wrote:

> Gregory Brown wrote:
>
>> On 2/22/06, Anthony DeRobertis <aderobertis@metrics.net> wrote:
>>> Take the following snippet:
>>
>> why do string conversion?
>>
>> You can pass constants around in ruby just fine.
>
> I'm scanning a directory for plugins and loading them. When I load a
> file called, for example, some_plugin.rb, I assume it creates a class
> Whatever::Plugins::SomePlugin, which I naturally only have as a
> string...

You can do this without using the name assumptions in Ruby, if you
give them a class to inherit from. Classes get notified when they
are subclassed:

>> class Plugin
>> def self.inherited( plugin_class )
>> (@@plugins ||= Array.new) << plugin_class
>> end
>> def self.loaded
>> @@plugins || Array.new
>> end
>> end
=> nil
>> class FirstPlugin < Plugin; end
=> nil
>> class SecondPlugin < Plugin; end
=> nil
>> Plugin.loaded
=> [FirstPlugin, SecondPlugin]

Hope that gives you some fresh ideas.

James Edward Gray II



Michael Trier

2/23/2006 4:14:00 PM

0

Thanks for the info. I'll have to keep that in mind.

Michael


Science

9/1/2009 2:26:00 PM

0

On Mon, 31 Aug 2009 21:33:47 -0700, tankfixer
<paul.carrier@gmail.com> wrote:

>> There was only ONE Tsar
>
>hahahahahahaha
>

>Nicolas was but the last in a long line of Czars..

By his time---there was no reform he would have been
able to institute

Land reform only allowed those who lived on it to eat.

"redistribution" of the wealth (of the nation) includes
all manners of building the nation

Science

9/1/2009 2:27:00 PM

0

On Mon, 31 Aug 2009 21:35:49 -0700, tankfixer
<paul.carrier@gmail.com> wrote:

>>
>> The issue is generations BEFORE the
>> "communists"---which came AFTER the Tsar.
>
>Can I send you a history book or three ?
>You are really out of your depth here

Arguing that "communists" had anything to do with prior
historical excesses of Tsars is utter nonsense

Ron Hamilton

9/1/2009 2:29:00 PM

0

Science@Science.com wrote:
> On Mon, 31 Aug 2009 20:04:05 -0700, Wilson Woods
> <banmilk@hotmail.com> wrote:
>
>> I agree that you don't know what the fuck you're talking about regarding
>> the Russian revolution.
>
> Agreeing with

with you. I'm agreeing with you that you don't know what the fuck
you're talking about regarding the Russian revolution.

Ron Hamilton

9/1/2009 2:32:00 PM

0

Science@Science.com wrote:
> On Mon, 31 Aug 2009 21:33:47 -0700, tankfixer
> <paul.carrier@gmail.com> wrote:
>
>>> There was only ONE Tsar
>> hahahahahahaha
>>
>
>> Nicolas was but the last in a long line of Czars..
>
> By his time---there was no reform he would have been
> able to institute

Sufficient reform had already been done.

Ron Hamilton

9/1/2009 2:32:00 PM

0

Science@Science.com wrote:
> On Mon, 31 Aug 2009 21:35:49 -0700, tankfixer
> <paul.carrier@gmail.com> wrote:
>
>>> The issue is generations BEFORE the
>>> "communists"---which came AFTER the Tsar.
>> Can I send you a history book or three ?
>> You are really out of your depth here
>
> Arguing that

You are out of your depth. You don't know history; you don't know anything.

tankfixer

9/1/2009 6:04:00 PM

0

In article <ljbq95h42rnkgno78d9ggeeq4e75lt7gtg@4ax.com>,
Science@Science.com says...
>
> On Mon, 31 Aug 2009 21:33:47 -0700, tankfixer
> <paul.carrier@gmail.com> wrote:
>
> >> There was only ONE Tsar
> >
> >hahahahahahaha
> >
>
> >Nicolas was but the last in a long line of Czars..
>
> By his time---there was no reform he would have been
> able to institute

No society has undergone instantanious change and been able to survie.

>
> Land reform only allowed those who lived on it to eat.

It was a step in the right direction.

>
> "redistribution" of the wealth (of the nation) includes
> all manners of building the nation

So what would have been your solution in early 20th century Russia ?

tankfixer

9/1/2009 6:05:00 PM

0

In article <8nbq9597srtg3ofo8nc40m56ofov6kg66l@4ax.com>,
Science@Science.com says...
>
> On Mon, 31 Aug 2009 21:35:49 -0700, tankfixer
> <paul.carrier@gmail.com> wrote:
>
> >>
> >> The issue is generations BEFORE the
> >> "communists"---which came AFTER the Tsar.
> >
> >Can I send you a history book or three ?
> >You are really out of your depth here
>
> Arguing that "communists" had anything to do with prior
> historical excesses of Tsars is utter nonsense

You said they didn't exist earlier..
Changing your mind or just catching up on your homework ?