[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

How to Call a static method?

Daniel Völkerts

10/3/2006 2:06:00 PM

Hi there, after I searched the ruby-doc.org site I couldn't find a hint
how to call a class method on different classes.

I've a helper class which parses a text input and which should either call

Role.something or

Organisation.anotherthing

depening which parameter was passed.

Please give a little hint to proceed. Thanks a lot...
--
Daniel Völkerts
Protected by Anti Pesto. -- Wallace & Gromit

24 Answers

Logan Capaldo

10/3/2006 2:14:00 PM

0

On Tue, Oct 03, 2006 at 11:05:43PM +0900, Daniel V?lkerts wrote:
> Hi there, after I searched the ruby-doc.org site I couldn't find a hint
> how to call a class method on different classes.
>
> I've a helper class which parses a text input and which should either call
>
> Role.something or
>
> Organisation.anotherthing
>
> depening which parameter was passed.
>
> Please give a little hint to proceed. Thanks a lot...
Just do it
if condition
Role.something
else
Organisation.anotherthing
end

Nothing special.

Simen

10/3/2006 2:17:00 PM

0

On 10/3/06, Daniel Völkerts <daniel@voelkerts.de> wrote:
> Hi there, after I searched the ruby-doc.org site I couldn't find a hint
> how to call a class method on different classes.
>
> I've a helper class which parses a text input and which should either call
>
> Role.something or
>
> Organisation.anotherthing
>
> depening which parameter was passed.
>
> Please give a little hint to proceed. Thanks a lot...
> --
> Daniel Völkerts
> Protected by Anti Pesto. -- Wallace & Gromit
>
>

class Test
def self.test
puts "The huge test...OF DOOM!"
end
end
Test.test # => The huge test...OF DOOM!

Test.test isn't really a static method, but a singleton method on
Test. Then just do a test in your method:

def call_one_or_the_other(x)
case x
when SomeClass
Role.something
when OtherClass
Organisation.anotherthing
end
end

--
- Simen

Daniel Völkerts

10/3/2006 2:20:00 PM

0

Okay, misleading question.

What if I like to call the classes dynamically e.g.

def mymethod(class,method)
call(class,method,options)
end

?

Where call is the Ruby function I'm looking for.

greetings,
--
Daniel Völkerts
Protected by Anti Pesto. -- Wallace & Gromit

Jano Svitok

10/3/2006 2:31:00 PM

0

On 10/3/06, Daniel Völkerts <daniel@voelkerts.de> wrote:
> Okay, misleading question.
>
> What if I like to call the classes dynamically e.g.
>
> def mymethod(class,method)
> call(class,method,options)
> end
>
> ?
>
> Where call is the Ruby function I'm looking for.

Class.send(:method, *options) or

const_get('Class').send(:method, *options)

possibly

const_get('Class').send(:method, *options, &block) but i'm not sure
with this one.

Logan Capaldo

10/3/2006 2:31:00 PM

0

On Tue, Oct 03, 2006 at 11:19:55PM +0900, Daniel V?lkerts wrote:
> Okay, misleading question.
>
> What if I like to call the classes dynamically e.g.
>
> def mymethod(class,method)
> call(class,method,options)
> end
>
> ?
>
> Where call is the Ruby function I'm looking for.
send
>
> greetings,
> --
> Daniel V?lkerts
> Protected by Anti Pesto. -- Wallace & Gromit

Daniel Völkerts

10/3/2006 2:38:00 PM

0

Jan Svitok schrieb:

>> Where call is the Ruby function I'm looking for.
>
> Class.send(:method, *options) or
>
> const_get('Class').send(:method, *options)
>
> possibly
>
> const_get('Class').send(:method, *options, &block) but i'm not sure
> with this one.

Great const_get('Classname').send is what I'm looking for. TIA!


--
Daniel Völkerts
Protected by Anti Pesto. -- Wallace & Gromit

mandryka

8/22/2011 5:20:00 AM

0

On Aug 22, 3:24 am, Miguel Montfort <op...@web.de> wrote:
> Tom Deacon wrote:
> > What one would wish for, of course, is some NEW repertoire
> > from AW which he did not choose to record.
>
> I would have thought the 4th Ballade to be a first. Is there
> another recording I’m not aware of?
>
> Miguel

I think it's his only recording of any Chopin ballade

pianomaven

8/22/2011 9:26:00 AM

0

On Aug 21, 10:24 pm, Miguel Montfort <op...@web.de> wrote:
> Tom Deacon wrote:
> > What one would wish for, of course, is some NEW repertoire
> > from AW which he did not choose to record.
>
> I would have thought the 4th Ballade to be a first. Is there
> another recording I’m not aware of?

Yes, Miguel, but one 8' piece is not exactly what I was thinking of,
you know.

The piano repertoire is enormous; AW recorded so little of it in the
end. This is the pity.

And no more will come from his hands today.

TD

pianomaven

8/22/2011 9:28:00 AM

0

On Aug 22, 1:20 am, mandryka <howie.st...@googlemail.com> wrote:
> On Aug 22, 3:24 am, Miguel Montfort <op...@web.de> wrote:
>
> > Tom Deacon wrote:
> > > What one would wish for, of course, is some NEW repertoire
> > > from AW which he did not choose to record.
>
> > I would have thought the 4th Ballade to be a first. Is there
> > another recording I’m not aware of?
>
> > Miguel
>
> I think it's his only recording of any Chopin ballade

Right. And he surely played them all. What about Brahms? Liszt?
Schubert? Schumann? And so on?

TD

mandryka

8/22/2011 9:49:00 AM

0

On Aug 22, 10:28 am, pianomaven <1pianoma...@gmail.com> wrote:
> On Aug 22, 1:20 am, mandryka <howie.st...@googlemail.com> wrote:
>
> > On Aug 22, 3:24 am, Miguel Montfort <op...@web.de> wrote:
>
> > > Tom Deacon wrote:
> > > > What one would wish for, of course, is some NEW repertoire
> > > > from AW which he did not choose to record.
>
> > > I would have thought the 4th Ballade to be a first. Is there
> > > another recording I’m not aware of?
>
> > > Miguel
>
> > I think it's his only recording of any Chopin ballade
>
> Right. And he surely played them all. What about Brahms? Liszt?
> Schubert? Schumann? And so on?
>
> TD


I would like more Haydn to be transferred. Steve, did you grok that?

Did he play much Mozart TD? I have a PC21 (Giulini and VSO) with an
extraordinary cadenza, but that's all.