P
Paul Vudmaska
Hi all,
Couple questions
1) I'm still pretty new to ruby.In my code i'm using quite a few classes
and i do not need multiple instances of most of them. So in lieu of
creating
a global object $obj = new SomeClass, i simply use the Class and
it's class methods/atts directly. Is this ok/good practice? Should I
just use these as modules in this case?
In simular situations w/javscript i do this:
instead of:
function class(){
this.prop = 0
}
obj = new class
... I use
obj = {
prop : 0
}
Which is kinda what i'm shooting for in Ruby.
2) I thot i would include a module with some generic class methods into
a class ie:
module Somemodule
self.boo
puts 'boo'
end
end
class SomeClass
include Somemodule
self.boohoo
# puts boo #dies cant find SomeClass method boo
puts Somemodule.boo #works ok
end
end
Should'nt the include pull those class meths into SomeClass?Am i causing
this issue/confusion by not intantiating objects from these classes?
Shoul I make this class
a module. I think i'll go try that....hmmm.
Thanks for any inight,paul
Couple questions
1) I'm still pretty new to ruby.In my code i'm using quite a few classes
and i do not need multiple instances of most of them. So in lieu of
creating
a global object $obj = new SomeClass, i simply use the Class and
it's class methods/atts directly. Is this ok/good practice? Should I
just use these as modules in this case?
In simular situations w/javscript i do this:
instead of:
function class(){
this.prop = 0
}
obj = new class
... I use
obj = {
prop : 0
}
Which is kinda what i'm shooting for in Ruby.
2) I thot i would include a module with some generic class methods into
a class ie:
module Somemodule
self.boo
puts 'boo'
end
end
class SomeClass
include Somemodule
self.boohoo
# puts boo #dies cant find SomeClass method boo
puts Somemodule.boo #works ok
end
end
Should'nt the include pull those class meths into SomeClass?Am i causing
this issue/confusion by not intantiating objects from these classes?
Shoul I make this class
a module. I think i'll go try that....hmmm.
Thanks for any inight,paul