find all member in a class
6 Message(s) by 5 Author(s) originally posted in ruby programming
| From: Pokkai Dokkai |
Date: Friday, October 26, 2007
|
| From: Robert Klemme |
Date: Friday, October 26, 2007
|
2007/10/26, Pokkai Dokkai
<bad_good_lion@xxxxxxxxxxx>:
how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
Do
ruby -e 'puts String.
method s.grep(/meth/)'
and go from there.
Kind regards
robert
| From: Paul |
Date: Friday, October 26, 2007
|
wrote in
message :
how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
--
Posted viahttp://www.ruby-forum.com/.
irb(main):002:0> puts String.methods.sort
<
<=
<=>
==
===
=~
=
__id__
__send__
allocate
ancestors
autoload
autoload?
class
class_eval
class_variable_defined?
class_variables
clone
const_defined?
const_get
const_missing
const_set
constants
display
dup
eql?
equal?
extend
freeze
frozen?
gem
hash
id
include?
included_modules
inspect
instance _eval
instance_method
instance_methods
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
kind_of?
method
method_defined?
methods
module_eval
name
new
nil?
object_id
private_class_method
private_instance_methods
private_method_defined?
private_methods
protected_instance_methods
protected_method_defined?
protected_methods
public_class_method
public_instance_methods
public_method_defined?
public_methods
require
require_gem
respond_to?
send
singleton_methods
superclass
taguri
taguri=
taint
tainted?
to_a
to_s
to_yaml
to_yaml_properties
to_yaml_style
type
untaint
yaml_as
yaml_new
yaml_tag_class_name
yaml_tag_read_class
yaml_tag_subclasses?
=> nil
| From: Rick DeNatale |
Date: Friday, October 26, 2007
|
wrote in message:
how to find all members list(member functions & member variables for all
access specifiers like public, private and protected) ?
--
Posted via http://www.ruby-forum.com/.
Note that unlike some languages with which you might be familiar,
"member" variables are not declared and only come into being when
defined during
code execution. In fact there's a
real difference
between that subtle vocabulary shift between "member" and "instance".
Different instances of the same class might've different sets of
instance variables. In fact the same instance might acquire instance
variables over time:
class A
def I
@xxxxxxxxxxx ||= 42
end
def j
@xxxxxxxxxxx ||= "hello"
end
end
a1 = A.new
a1.instance_variables # => []
a1.i
a1.instance_variables # => ["@xxxxxxxxxxx"]
a1.j
a1.instance_variables # => ["@xxxxxxxxxxx", "@xxxxxxxxxxx"]
AND, since
Ruby allows instances to have singleton methods, it's even
possible for two instances of the same class to have different sets of
methods.
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/
| From: trebor777 |
Date: Saturday, October 27, 2007
|
wrote in message:
wrote in message:
class A
def I
@xxxxxxxxxxx ||= 42
end
Some rudimentary explanation please:
the def is to define a method?
it's a coincidence that the method name is "i" and the instance variable
has the same name, "I"?
the third
line declares an instance variable, "i", what do the "||" do in
that line, please?
thanks,
Thufir
Yeap "def" is to define a method
It could be a coincidence... or not, depends on what you want to do with
this method... hum Here it's not a coincidence... this method return the
value of the instance variable I (it's a reader accessor) or if it's nil,
set it to 42 and return it.
basically || means "if it's nil do that ", then = assigns the value 42 to @xxxxxxxxxxx
View this message in context:
http://www.nabble.com/find-all-member-in-a-class-tf4695579.html#a13442171
Sent from the ruby-talk mailing list
archive at Nabble.com.
| From: Rick DeNatale |
Date: Saturday, October 27, 2007
|
wrote in message:
wrote in message:
>
wrote in message:
>
>
class A
def I
@xxxxxxxxxxx ||= 42
end
>
>
> Some rudimentary explanation please:
>
> the def is to define a method?
> it's a coincidence that the method name is "i" and the instance variable
> has the same name, "I"?
>
>
> the third line declares an instance variable, "i", what do the "||" do in
> that line, please?
>
>
>
> thanks,
>
> Thufir
>
>
>
>
Yeap "def" is to define a method
It could be a coincidence... or not, depends on what you want to do with
this method... hum Here it's not a coincidence... this method return the
value of the instance variable I (it's a reader accessor) or if it's nil,
set it to 42 and return it.
basically || means "if it's nil do that ", then = assigns the value 42 to @xxxxxxxxxxx
Correct, it's an
attribute reader with lazy initialization of the
instance variable.
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/
Next Message: State of the art in setup.rb land?
Blogs related to find all member in a class
When you take a wax depilation course, you will find that the ...
Besides chromophore that you should understand about is hemoglobin which is known to eventuate in a characteristic way in the blush and it is also what gives the
ruby the
ruby color. The last chromophore that you should notice about is
...
paterson ymca's seniors find fitness
Up on the Y's fourth floor on the following Thursday, in a racquetball court with an Everlast punching-bag stand in one corner and stationary bikes platooned against the far wall behind rectangular mats, 11
class members follow Bacote's
...
List of Greek Mythological Characters
stuthorpe. restaurant coupons in columbia, sc
ruby sapphire walkthrough saint 420 new moms best friend vmk quest rss feed 92 3496 8573 98 a/sa-182 ... symbyax list
all hotels in malta dons auto parts binghamton new york britinnia
...
[Announcements] From First Unitarian Universalist Church of Austin
Philosophical Inquiry Discussion Group: in Room 13 at noon. Tai Chi Chuan: in Room 15 at 7 pm. Thursday, November 1:.
Ruby Zener our oldest
member will be 103 TODAY. Happy Birthday
Ruby!!
Ruby is Ann Edwards’ mother.
...
Social bookmarking sites uncovered Listed [300+] all tested and live
alt=”" /> myComments:[PR5] every time you post a comment in any blog that has the plugin installed, myComments alerts via RSS
all the other conversation
members. mynoteIT:[PR5] Online
class rooms. (Groups, classes, calendar, shredules…
...
Desert Greens Green Party of Utah member speaks on Environmental ...
Use your imagination;
find the points you have in common with other communities, both geographical and ideological. You might focus on water; water affects everyone;
all water is connected.
Find grassroots organizations with whom you
...