Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Class of the calling Object, is there someway to fetch it (from thecalled method)?

Reply
Thread Tools

Class of the calling Object, is there someway to fetch it (from thecalled method)?

 
 
thunk
Guest
Posts: n/a
 
      03-27-2010

Hi again,

SPECIFIC QUESTION:
How can I fetch the Class name of the calling Object?
(The module that contains the class of the calling Object might be
useful/necessary in the future.)

NOTES:
I checked the 'caller' stack and it doesn't show up there. Searched
this forum, googled, and it is was not found.

The calling Method was found right off.



A SNIPPIT FROM MY TEST CODE:
(this might provide some clue to the general utility?)

class TestingClass

def initialize
@wB = WhiteBoard.new
@satz1 =
end

def calling_method1
age = @wB.get_note(:AGE, 19)
puts "defaulted age = " + age.to_s
@wB.put_note(:test, 12)
@wB.put_note(:test, 16) #just overwrites, handy?!
age = @wB.get_note(:test)
puts "age = " + age.to_s # => 16
end

def calling_method2
@wB.set_id( :ALF )
@wB.put_satz(:TestingClass, :calling_method2, @satz1)
#put_satzAr(.... pushes the satz struct onto a automatic
stack

#would become just
#@wB.put_satz(@satz1)
#....if I could fetch the Class
end

def calling_method3
@wB.set_id( :ALF )
satz = @wB.get_satz(:TestingClass, :calling_method2)
puts "satz in calling_method3 = " + satz.inspect #(this
works)
end

end



 
Reply With Quote
 
 
 
 
Ryan Davis
Guest
Posts: n/a
 
      03-27-2010

On Mar 26, 2010, at 18:15 , thunk wrote:

> def calling_method1
> age =3D @wB.get_note(:AGE, 19)
> puts "defaulted age =3D " + age.to_s
> @wB.put_note(:test, 12)
> @wB.put_note(:test, 16) #just overwrites, handy?!
> age =3D @wB.get_note(:test)
> puts "age =3D " + age.to_s # =3D> 16
> end


This is not a test (nor is any of the rest of your file).

Also, it hints very much that you're reimplementing rinda, as I've =
suspected for a while. Google for Linda TupleSpace for more info.


 
Reply With Quote
 
 
 
 
thunk
Guest
Posts: n/a
 
      03-27-2010
On Mar 26, 9:45*pm, Ryan Davis <(E-Mail Removed)> wrote:
> On Mar 26, 2010, at 18:15 , thunk wrote:
>
> > * *def calling_method1
> > * * * *age = @wB.get_note(:AGE, 19)
> > * * * *puts "defaulted age = " + age.to_s
> > * * * *@wB.put_note(:test, 12)
> > * * * *@wB.put_note(:test, 16) * #just overwrites, handy?!
> > * * * *age = @wB.get_note(:test)
> > * * * *puts "age = " + age.to_s * # => 16
> > * *end

>
> This is not a test (nor is any of the rest of your file).
>
> Also, it hints very much that you're reimplementing rinda, as I've suspected for a while. Google for Linda TupleSpace for more info.



1. I don't know from "tuples" - all I "need" are hashes. Somebody
also mentioned Graphs. I'm happy with my set of conventions and these
hashes for my purposes.

2. I looked at Rinda and didn't understand it.

3. Anything that works for me in 60 lines and I have complete control
over is not something I am personally interested in replacing with
something I don't understand or see a need to.

4. Any thing I write that "tests" is a "test" to my simple logic. I'm
spending a great deal of time implementing self-tests and all such and
have written and supervised some pretty big projects in other
languages. I'm in awe of what Ruby can do but I don't really think
you guys, as awesome as you all are, have any place telling that I'm
not testing. Save that for the rookies. Or maybe you have redefined
what "testing" means. As an old QC guy, i'd have to wonder if you can
do that.

 
Reply With Quote
 
thunk
Guest
Posts: n/a
 
      03-27-2010
On Mar 26, 10:07*pm, thunk <(E-Mail Removed)> wrote:
> On Mar 26, 9:45*pm, Ryan Davis <(E-Mail Removed)> wrote:
>
> > On Mar 26, 2010, at 18:15 , thunk wrote:

>
> > > * *def calling_method1
> > > * * * *age = @wB.get_note(:AGE, 19)
> > > * * * *puts "defaulted age = " + age.to_s
> > > * * * *@wB.put_note(:test, 12)
> > > * * * *@wB.put_note(:test, 16) * #just overwrites, handy?!
> > > * * * *age = @wB.get_note(:test)
> > > * * * *puts "age = " + age.to_s * # => 16
> > > * *end

>
> > This is not a test (nor is any of the rest of your file).

>
> > Also, it hints very much that you're reimplementing rinda, as I've suspected for a while. Google for Linda TupleSpace for more info.

>
> 1. *I don't know from "tuples" - all I "need" are hashes. * Somebody
> also mentioned Graphs. *I'm happy with my set of conventions and these
> hashes for my purposes.
>
> 2. I looked at Rinda and didn't understand it.
>
> 3. Anything that works for me in 60 lines and I have complete control
> over is not something I am personally interested in replacing with
> something I don't understand or see a need to.
>
> 4. Any thing I write that "tests" is a "test" to my simple logic. *I'm
> spending a great deal of time implementing self-tests and all such and
> have written and supervised some pretty big projects in other
> languages. *I'm in awe of what Ruby can do but I don't really think
> you guys, as awesome as you all are, have any place telling that I'm
> not testing. *Save that for the rookies. *Or maybe you have redefined
> what "testing" means. *As an old QC guy, i'd have to wonder if you can
> do that.


Project perspective wise this "WhiteBoard" thing is a very small part
of a much larger project. It looks like it can have a role in storing
and retrieving "communications" between DSLs that are handling the
"Boids" and between HelperClasses and the end resulting
"WorkSheets" (back into technish). Line of code wise this is maybe
80/4000 if you don't count the Boids (another 4,000 and growing
rapidly).

.....just for some perspective.
 
Reply With Quote
 
thunk
Guest
Posts: n/a
 
      03-27-2010

OK!

SUMMARY
I have been to the mountain top and gotten this from a Ruby Guru -
there are two ways of getting at the class but one way is a hack, and
not a pretty one, or even what appears to be a reliable one. And the
2nd way, using binding, seems to require a param - which is what I was
trying avoid.

RAMBLINGS
Since I've become totally stuck on this "keyLess entry" for now, at
least to play with for awhile, I have decided to do something a little
strange - I'm going to require that all the method names in all the
involved sending libraries are unique - a non-unique new method will
just need a tweak and the whole system can work on the method name
alone as the key. A nice friendly message will come up and tell a
contributing writer that his carefully thought out name needs to get
tweaked - or I could append a tie breaker to it - and just give it to
him.

LINK TO A GIST - It might have some use for somebody with enough
changes, it sure has been interesting to play with.

http://gist.github.com/345646
 
Reply With Quote
 
Ryan Davis
Guest
Posts: n/a
 
      03-27-2010

On Mar 26, 2010, at 20:10 , thunk wrote:

> 1. I don't know from "tuples" - all I "need" are hashes. Somebody
> also mentioned Graphs. I'm happy with my set of conventions and these
> hashes for my purposes.


> 2. I looked at Rinda and didn't understand it.


> ... and the rest


DTM

you flipped the bozo bit.


 
Reply With Quote
 
thunk
Guest
Posts: n/a
 
      03-27-2010
On Mar 27, 4:14*am, Ryan Davis <(E-Mail Removed)> wrote:
> On Mar 26, 2010, at 20:10 , thunk wrote:
>
> > 1. *I don't know from "tuples" - all I "need" are hashes. * Somebody
> > also mentioned Graphs. *I'm happy with my set of conventions and these
> > hashes for my purposes.
> > 2. I looked at Rinda and didn't understand it.
> > ... and the rest

>
> DTM
>
> you flipped the bozo bit.


 
Reply With Quote
 
thunk
Guest
Posts: n/a
 
      03-27-2010
On Mar 27, 4:14*am, Ryan Davis <(E-Mail Removed)> wrote:
> On Mar 26, 2010, at 20:10 , thunk wrote:
>
> > 1. *I don't know from "tuples" - all I "need" are hashes. * Somebody
> > also mentioned Graphs. *I'm happy with my set of conventions and these
> > hashes for my purposes.
> > 2. I looked at Rinda and didn't understand it.
> > ... and the rest

>
> DTM
>
> you flipped the bozo bit.



Are you really trying to tell me I "need" a tuples Gem with no (found)
documentation, to replace my 80 line class that does what I need?

You can tell me that rather than use something I'm comfortable, wrote
100% myself, I should use a Gem from folks I don't know, with overhead
I don't know, with quality issues I have no way to estimate, and
support I can only guess at, to do something I haven't a clue why I
would need?

My first app generated apps as a R&D manager for McGraw-Hill back in
1984. Since then my apps have done what I designed them to do, and I
have never failed to finish a project I started. I have delivered,
documented, and supported FIVE large scale commercial projects, how
many have you?

(They happened to have been in the field of STATISTICAL PROCESS
CONTROL - we trained folks at HP, John Deere, Mercury Marine and other
corps on how to use this software. My reseller were the two largest
precision tool manufacturers in the World - Mitutoyo and Brown &
Sharpe.)

So do you really think you invented Testing and have a patient on it
or something?



Thunk





 
Reply With Quote
 
thunk
Guest
Posts: n/a
 
      03-27-2010
Ryan,


I'm a "step-wise-refinement" guy. it worked for me for many years, and
I think I can make a good case for it against any other kind of
development, when and where it can be used. There's more to it than
one might think, it is a way to follow one's instincts and work to
strengths and let the code show you where to go next.

Some folks will understand that, some won't. If you don't, I suspect
you are missing some of the real joy of programming.

Or maybe you think it is all science?


Thunk

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a faster way to fetch data from stl map? Steve555 C++ 21 12-28-2008 01:38 PM
How to fetch the class object returnd from C# dll to VC++???? jklioe C++ 0 10-31-2006 06:32 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Is there any library to get/fetch a remote URL? Francesco Moi C Programming 13 10-06-2004 10:50 PM
Is there a method to fetch the last value stored in a DB column with out having to read in the entire column? DeWitt Phillips ASP .Net 2 12-12-2003 11:29 AM



Advertisments