PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > where is that method defined?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
where is that method defined?

Réponse
 
LinkBack Outils de la discussion
Vieux 08/01/2008, 17h20   #1
Alex Ma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut where is that method defined?

I'm looking at ruby code for a class, for which I can call a method but
which I don't find in the class source code.

I suppose this is a feature of Ruby that I have yet to learn.
Can anyone me please?

Specifically, the class is Cipher in openssl module (fully qualified
class name s OpenSSL::Cipher::Cipher) and its source code in Ruby
library is:

class Cipher
def random_key
str = OpenSSL::Random.random_bytes(self.key_len)
self.key = str
return str
end

def random_iv
str = OpenSSL::Random.random_bytes(self.iv_len)
self.iv = str
return str
end
end

Where does this class defines the cipher method?

Thanks!
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 08/01/2008, 17h27   #2
Markus Schirp
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is that method defined?

Am Wed, 9 Jan 2008 02:20:26 +0900
schrieb Alex Ma <alessio.spam@gmail.com>:

> I'm looking at ruby code for a class, for which I can call a method
> but which I don't find in the class source code.
>
> I suppose this is a feature of Ruby that I have yet to learn.
> Can anyone me please?
>
> Specifically, the class is Cipher in openssl module (fully qualified
> class name s OpenSSL::Cipher::Cipher) and its source code in Ruby
> library is:
>
> class Cipher
> def random_key
> str = OpenSSL::Random.random_bytes(self.key_len)
> self.key = str
> return str
> end
>
> def random_iv
> str = OpenSSL::Random.random_bytes(self.iv_len)
> self.iv = str
> return str
> end
> end
>
> Where does this class defines the cipher method?
>
> Thanks!


The method may be defined in an C extension. Download ruby sources
and lookup under 'ext' directory.

--
Seonic IT-Systems GbR
Anton Shatalov & Markus Schirp
Kopernikusstr.6
D-51789 Lindlar
---
www.seonic.net
info@seonic.net

  Réponse avec citation
Vieux 08/01/2008, 17h33   #3
Mike McKinney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is that method defined?

[Note: parts of this message were removed to make it a legal post.]

it's in C:
<ruby_src>/ext/openssl/ossl_ssl.c line 899 (for ruby 1.8.6 source)
rb_define_method(cSSLSocket, "cipher", ossl_ssl_get_cipher, 0);


On Jan 8, 2008 12:20 PM, Alex Ma <alessio.spam@gmail.com> wrote:

> I'm looking at ruby code for a class, for which I can call a method but
> which I don't find in the class source code.
>
> I suppose this is a feature of Ruby that I have yet to learn.
> Can anyone me please?
>
> Specifically, the class is Cipher in openssl module (fully qualified
> class name s OpenSSL::Cipher::Cipher) and its source code in Ruby
> library is:
>
> class Cipher
> def random_key
> str = OpenSSL::Random.random_bytes(self.key_len)
> self.key = str
> return str
> end
>
> def random_iv
> str = OpenSSL::Random.random_bytes(self.iv_len)
> self.iv = str
> return str
> end
> end
>
> Where does this class defines the cipher method?
>
> Thanks!
> --
> Posted via http://www.ruby-forum.com/.
>
>


  Réponse avec citation
Vieux 08/01/2008, 17h38   #4
Mike McKinney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is that method defined?

[Note: parts of this message were removed to make it a legal post.]

FYI: I used the new netbeans 6 to find this quickly....

command+O: then type "Cipher", you will see two options near the top, both
in openssl.rb files but one is in a directory called "rubystubs" which tells
me right away it's in C and there isn't ruby source available... the stub
file doesn't it's best to document even those defined methods but it's tough
if there is no documentation in the C layer. then you are off to the source
code for more snooping.

M

On Jan 8, 2008 12:33 PM, Mike McKinney <mike.s.mckinney@gmail.com> wrote:

> it's in C:
> <ruby_src>/ext/openssl/ossl_ssl.c line 899 (for ruby 1.8.6 source)
> rb_define_method(cSSLSocket, "cipher", ossl_ssl_get_cipher, 0);
>
>
>
> On Jan 8, 2008 12:20 PM, Alex Ma < alessio.spam@gmail.com> wrote:
>
> > I'm looking at ruby code for a class, for which I can call a method but
> > which I don't find in the class source code.
> >
> > I suppose this is a feature of Ruby that I have yet to learn.
> > Can anyone me please?
> >
> > Specifically, the class is Cipher in openssl module (fully qualified
> > class name s OpenSSL::Cipher::Cipher) and its source code in Ruby
> > library is:
> >
> > class Cipher
> > def random_key
> > str = OpenSSL::Random.random_bytes(self.key_len)
> > self.key = str
> > return str
> > end
> >
> > def random_iv
> > str = OpenSSL::Random.random_bytes(self.iv_len)
> > self.iv = str
> > return str
> > end
> > end
> >
> > Where does this class defines the cipher method?
> >
> > Thanks!
> > --
> > Posted via http://www.ruby-forum.com/.
> >
> >

>


  Réponse avec citation
Vieux 08/01/2008, 19h17   #5
Alex Ma
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is that method defined?

Mike McKinney wrote:
> FYI: I used the new netbeans 6 to find this quickly....
>
> command+O: then type "Cipher", you will see two options near the top,


Thanks!

As an aside, I've just installed NetBeans 6 for Ruby to give it a try.
Probably it needs to be configured in order to behave like you're
mentioning. Or probably I need to be configured... :-)
What do you mean with command+0? I tried with 'Navigate->Go to
declaration', but it picks the wrong one.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 08/01/2008, 19h56   #6
Mike McKinney
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is that method defined?

[Note: parts of this message were removed to make it a legal post.]

command (mac) control (win)

declaration works for classes and variables (you can control+click to get
there right in your code)

but in this case, you want to choose... so you use go to type

Navigate > goto type... enter cipher and you should have a few options
there...

the first for me is the stubbed docs for the C impl... the second is the raw
ruby for the Cipher class. (you can see the "location" at the bottom of the
window which shows you where it'll take you when you click ok or hit
enter... rubystubs directory is where the generated ruby representing C impl
is stored.)

great videos and docs here: http://www.netbeans.org/features/ruby/index.html

NB also supports C/C++ development so you could pull the ruby source into
the same IDE for viewing if you like... I'll stop there, this is sounding
too much like a commercial.

M


On Jan 8, 2008 2:17 PM, Alex Ma <alessio.spam@gmail.com> wrote:

> Mike McKinney wrote:
> > FYI: I used the new netbeans 6 to find this quickly....
> >
> > command+O: then type "Cipher", you will see two options near the top,

>
> Thanks!
>
> As an aside, I've just installed NetBeans 6 for Ruby to give it a try.
> Probably it needs to be configured in order to behave like you're
> mentioning. Or probably I need to be configured... :-)
> What do you mean with command+0? I tried with 'Navigate->Go to
> declaration', but it picks the wrong one.
> --
> Posted via http://www.ruby-forum.com/.
>
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h33.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15827 seconds with 14 queries