rubyists-
any ideas how to refer to the top level ‘self’ in a ruby program, that is to
say the self where self.to_s() == “main”
eg (intent - obviously doesn’t work):
class Klass
top_level_self = ::self
…
top_level_self.instance_eval ‘code’
end
-a
···
–
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================
thanks!
so it would seem that
path = ‘config.rb’
(eval(“self”, TOPLEVEL_BINDING)).instance_eval(IO.readlines(path, nil)[0])
is a reasonable way to pull in configuration info from pure ruby files.
of course, this cannot be placed into a method or stack local variable would
disapear.
i know this has been kicked around before - but i don’t recall a nice clean
solution.
-a
···
On Tue, 22 Apr 2003 nobu.nokada@softhome.net wrote:
Hi,
At Tue, 22 Apr 2003 01:08:52 +0900, > ahoward wrote:
any ideas how to refer to the top level ‘self’ in a ruby program, that is to
say the self where self.to_s() == “main”
eval “self”, TOPLEVEL_BINDING
–
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================
i know this has been kicked around before
indeed; i.e.:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=1045634364.1063.294.camel%40traken&rnum=3&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1%26q%3Druby%2Bas%2Bconfig%2Bfile%26btnG%3DGoogle%2BSearch%26meta%3Dgroup%253Dcomp.lang.ruby
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=slrn9700sm.ef9.r2d2%40mao.acc.umu.se&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DISO-8859-1%26q%3Druby%2Bas%2Bconfig%2Bfile%26btnG%3DGoogle%2BSearch%26meta%3Dgroup%253Dcomp.lang.ruby
but i don’t recall a nice clean solution.
neither do I; let us know about your findings on this one if you please.
Thx,
Simon
PS: What about a YAML config file ? Doesn’t that come close to the kind
of flexibility we are looking for ? You can’t write loops or control
statements but you could put codeblocks in there couldn’t you ???
···
On Mon, 21 Apr 2003 16:55:26 +0000, ahoward ahoward@fsl.noaa.gov wrote:
–
There are 10 types of people in the world…
those who understand binary and those who don’t.
i’m looking at exactly this. the thing is, i have no need to share data
between ruby, perl, etc but DO have a need to have configurable Proc objects
so YAML seems a bit too general for me. this topic certainly sparks interest
for inlining pure ruby configuration files.
though
load "config.rb", Module
comes close
if i don’t hack something together myself i’m sure i will use YAML - it looks
really nice.
-a
···
On Mon, 21 Apr 2003, Simon Vandemoortele wrote:
but i don’t recall a nice clean solution.
neither do I; let us know about your findings on this one if you please.
Thx,
Simon
PS: What about a YAML config file ? Doesn’t that come close to the kind
of flexibility we are looking for ? You can’t write loops or control
statements but you could put codeblocks in there couldn’t you ???
–
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================