Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
[ANN] parseargs-0.0.0
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ara.T.Howard, post: 4472220"] the problem here is that the variables will only be __available__ through eval either. eg. you'd have to p 'eval a' and could never p a i seem to recall a way of working around this but can't remember the thread... if i can figure it out i'll add this feature. currently parsearges supports an undoccumented feature, if you parseargs(argv => receiver) { arg 'a' kw 'b' } then receiver will be used to 'receive' the arguments. this works by begin receiver.send '[]=', name, value rescue NoMethodError begin receiver.send "#{ name }=", value rescue NoMethodError receiver.send "#{ name }", value end end eg. any object that responds_to? []=, #{name}=, or #{name} can be used. examples would be parseargs(argv => a_hash) { arg 'a' kw 'b' } or parseargs(argv => a_open_struct) { arg 'a' kw 'b' } and those objects will be parsed 'into'. this means that, if a way can be found to 'set the variable a, given the string "a", in the current scope' i could have the following work fine parseargs(argv => binding) { arg 'a' kw 'b' } p a p b to accomplish what you want. so. how can one do this?? eval 'a = 42' p a i don't know how... -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso =============================================================================== [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
[ANN] parseargs-0.0.0
Top