[#387246] newbie question — sunny parker <info@2020proj.com>
i am coming from php and dont seem to quite understand how ruby works
You will need a framework like rails or sinatra to do web "stuff". I
[#387251] irb Pleca ("pipe") teclado — Diego Pereira <dipetete@...>
Buenas noches,
[#387283] ri_for 0.6.0 released--easy lookup of method documentation in irb — Roger Pack <rogerpack2005@...>
Hello all.
On Fri, Sep 2, 2011 at 5:23 AM, Roger Pack <rogerpack2005@gmail.com> wrote:
[#387308] Twofish v0.5.0 released — transfire@...
Twofish 0.5.0 has been released.
[#387311] Newfish v0.5.0 released — transfire@...
Newfish 0.5.0 has been released.
[#387330] installing naive bayes classifier — aya abdelsalam <ayoya_91@...>
Hello
[#387344] Beginner needing help - Writing right-angle triangle program — Kane Williams <theburrick@...>
I've been going through a Haskell tutorial (Just to see what it's like)
Thanks for the reply!
[#387347] Beginner needing help - Writing right-angle triangle program — "Patrick Lynch" <kmandpjlynch@...>
I've been going through a Haskell tutorial (Just to see what it's like)
On Sep 3, 2011, at 7:49 AM, Patrick Lynch wrote:
On Sat, Sep 3, 2011 at 4:36 PM, Gavin Kistner <phrogz@me.com> wrote:
On Sep 3, 2011, at 2:16 PM, Adam Prescott <adam@aprescott.com> wrote:
[#387356] Which version should I download? — Vladimir Van Bauenhoffer <cluny_gisslaren@...>
Im new to programming and Im thinking of downloading and starting with
[#387363] opening a file with variable name — Jeffrey Smith <jesmith2095@...>
Hello All,
On Sat, Sep 3, 2011 at 2:59 PM, Jeffrey Smith <jesmith2095@gmail.com> wrote:
Hello Hassan,
On Sat, Sep 3, 2011 at 3:27 PM, Jeffrey Smith <jesmith2095@gmail.com> wrote:
I changed the slashed and escaped the file path ( I noticed after the =
[#387367] arrays(setters and getters) — jack jones <shehio_22@...>
# whats wrong with that
[#387392] loops problem — jack jones <shehio_22@...>
for (j = @array.length ; j > counter ; j = j-1) # counter is a variable
I've read about the method which inserts some element in a certain place
[#387408] Ruby and XML — Bob Aiello <raiello@...>
Hi Everyone,
[#387424] read .gz file directly — CC Chen <dickyhide@...>
How to read the xxx.gz file directly and don't decompress the file.
[#387451] Conditional expression and return — Philipp Altmann <altmann.work@...>
Hi guys,
[#387468] Grouping an array into sub-arrays. — Intransition <transfire@...>
Is there a method out there already that does anything like this?
On Tue, Sep 6, 2011 at 11:47 PM, Intransition <transfire@gmail.com> wrote:
[#387469] posts on Unix systems programming — Eric Wong <normalperson@...>
I would like to do a series of mailing list posts on the subject of Unix
On Wed, Sep 7, 2011 at 4:30 AM, Eric Wong <normalperson@yhbt.net> wrote:
Eric Wong wrote in post #1020497:
On Wed, Sep 7, 2011 at 12:00 AM, Eric Wong <normalperson@yhbt.net> wrote:
Sean O'Halpin <sean.ohalpin@gmail.com> wrote:
[#387497] TCPSocket recv's nil with gets() if the server crashes? — "Bill W." <sirwillard42@...>
I don't claim to be much of a programmer, and I am also new to RUBY, so
[#387504] Ruby for multiple platforms — James French <James.French@...>
Morning,
[#387513] green shoes on archlinux x64 error... — serialhex <serialhex@...>
ok, so i brought this up in the shoes ML, and they suggested i ask here.
Hi hex,
[#387530] Unexpected behavior of Ruby array — Suvankar Satpati <suvankar.17@...>
I was going through the exercises at http://rubykoans.com/ and got
There's discussion about this at http://www.ruby-forum.com/topic/1393096
On Sep 8, 2011, at 4:08 AM, Adam Prescott wrote:
On Thu, Sep 8, 2011 at 10:15 PM, Gary Wright <gwtmp01@mac.com> wrote:
On Fri, Sep 9, 2011 at 1:36 PM, Robert Klemme
[#387537] help with LOAD_PATH when building from source on Mac OSX Lion — James French <James.French@...>
Hi all,
[#387544] Executing the output of a look — dwight schrute <spambocks@...>
Hi,
On Thu, Sep 8, 2011 at 3:35 PM, dwight schrute <spambocks@yahoo.ca> wrote:
[#387561] undefined method?? — Joe Collins <joec_49@...>
When I press MSG or EXIT buttons I get undefined method errrs for the
[#387563] usp.ruby - Unix systems programming in Ruby list — Eric Wong <normalperson@...>
A mailing list dedicated to Unix systems programming in Ruby
[#387566] Ruby Readline - do something when a key combination is pressed — Marc Heiler <shevegen@...>
Hi,
[#387573] Submitting a URL with Mechanize — dwight schrute <spambocks@...>
Hi,
[#387581] Regex Problem — "Cyril J." <cyril.varghese.jose@...>
Hello all,
[#387586] Creating a hash from two arrays — simon harrison <simonharrison.uk@...>
Hi. Can anyone help with this? I'd like to end with a hash like so:
Robert, I seem to remember that it was you who said you'd implemented
This works in 1.9 at least.
On Fri, Sep 9, 2011 at 6:15 PM, Aaron D. Gifford <astounding@gmail.com> wro=
[#387588] Strings in a Ruby 1.9 C extension? — "Aaron D. Gifford" <astounding@...>
Hi,
[#387596] newbie ruby installation malloc issue — "mark e." <mark_f_edwards@...>
hi all -
thanks josh.
On Sun, Sep 11, 2011 at 12:42 PM, mark e. <mark_f_edwards@yahoo.com> wrote:
[#387605] Convert ruby.rb to msdos exe file? — Joe Collins <joec_49@...>
I am rewriting numerous vbscript programs in ruby. Is there a way to
[#387607] Large file reading — "Cyril J." <cyril.varghese.jose@...>
Hello all,
On Fri, Sep 9, 2011 at 10:38 PM, Cyril J. <cyril.varghese.jose@gmail.com> wrote:
[#387614] how to write data in binary to a file? — frank hi <yw_hi@163.com>
Hi,
frank hi wrote in post #1021069:
7stud -- wrote in post #1021082:
On Sat, Sep 10, 2011 at 6:52 PM, Brian Candler <b.candler@pobox.com> wrote:
Phillip Gawlowski wrote in post #1021166:
On Sun, Sep 11, 2011 at 5:15 AM, Brian Candler <b.candler@pobox.com> wrote:
[#387624] Not 2 maps — Harry Kakueki <list.push@...>
# I have this
A marginally faster solution would be
On Sat, Sep 10, 2011 at 11:43 PM, Bartosz Dziewo=C5=84ski
[#387626] Installing ruby on 5.4 throws errors and doesn't create the make file — sridhar pandurangiah <sridharpandu@...>
I am trying to install ruby on my VPS and I get strange errors. Didn't
[#387646] How do I make output generate a float without an excess numbers of decimal places? — Kane Williams <theburrick@...>
For example, my current code is
On Sep 11, 2011, at 5:05 AM, Kane Williams wrote:
I tried n.round(2) and gave an error - didnt want the 2 argument. I am
[#387652] making an array of strings — Joe Collins <joec_49@...>
I want to make an array of strings, i.e boy, girl, cat dog
[#387653] De-listing of ruby-doc.org on ruby-lang.org? — Matthew -- <astrochase@...>
This may have been brought up before, but as a newbie Ruby programmer,
On Sun, Sep 11, 2011 at 9:24 AM, Matthew -- <astrochase@gmail.com> wrote:
James Gray wrote in post #1021268:
On Sun, Sep 11, 2011 at 10:14 AM, Matthew -- <astrochase@gmail.com> wrote:
[#387663] example of tk drop down menu needed — Joe Collins <joec_49@...>
I want to have a drop down whereby when I click on it, I get a number of
[#387693] ruby 1.9.2 binary distribution for linux ? — "mark e." <mark_f_edwards@...>
hello all -
[#387694] 1.9.3 (and nightly snapshot) error — "mark e." <mark_f_edwards@...>
hello - several people have helped me try to get 1.9.2 installed with no
[#387700] Network user on Linux — Mario Ruiz <tcblues@...>
I am able to get the network user in windows though ENV['username'] but
[#387725] Any downsides to writing paranthesises? — Vladimir Van Bauenhoffer <cluny_gisslaren@...>
Im a newbie programmer who is trying to learn Ruby after having just
On Mon, Sep 12, 2011 at 4:16 PM, Vladimir Van Bauenhoffer
.serialhex .. wrote in post #1021524:
On Tue, Sep 13, 2011 at 05:50:35AM +0900, Vladimir Van Bauenhoffer wrote:
Just a convention. As long as you're just writing for yourself, do
On Tue, Sep 13, 2011 at 05:41:41AM +0900, Bartosz Dziewo=C5=84ski wrote:
[#387744] Can monkey patching be discovered when you require a library? — Nick Klauer <klauer@...>
Is it possible to know whether a method, class, or instance was overridden
[#387760] Iterate Array and (pretty)print — dwight schrute <spambocks@...>
Hi,
[#387767] Using a loop to run similar commands — dwight schrute <spambocks@...>
Hi again,
[#387772] Methods not found — Angelo Farias <angeloalvesfarias@...>
Web page throw: =E2=80=98undefined method `find' for =
[#387779] recommended way to support multiple APIs from one codebase — Chuck Remes <cremes.devlist@...>
I am the author of the ffi-rzmq gem. It wraps the 0mq [1] (libzmq) library for use by all of the major Ruby runtimes.
[#387784] examples of date, datetime classes needed — Joe Collins <joec_49@...>
I am running ruby 1.8.7 under windows xp, if that matters
[#387793] csv file use excel to open and modify — CC Chen <dickyhide@...>
I create csv script to read a csv file.
[#387806] Integers to English Words. — Nut Shell <conor.starrs@...>
Hi,
[#387811] Get interpreter path — Michal Suchanek <hramrach@...>
Hello,
> get current interpreter path
On Wed, Sep 14, 2011 at 3:35 PM, Michal Suchanek <hramrach@centrum.cz> wrot=
On 14 September 2011 20:47, Phillip Gawlowski <cmdjackryan@gmail.com> wrote:
On Wed, Sep 14, 2011 at 8:56 PM, Michal Suchanek <hramrach@centrum.cz> wrot=
On 14 September 2011 21:06, Phillip Gawlowski <cmdjackryan@gmail.com> wrote:
On Thu, Sep 15, 2011 at 12:09 AM, Michal Suchanek <hramrach@centrum.cz> wro=
On 15 September 2011 01:12, Phillip Gawlowski <cmdjackryan@gmail.com> wrote:
[#387814] Tough Ruby Homework — Rory Pascua <rorypascua@...>
I'm trying to take a long piece of text, find a word, and get that word
...if it's homework, why are you simply asking us?
[#387823] weird behaviour spawning processes — James French <James.French@...>
Hi,
[#387831] Find memory leak in very complex Ruby app — Tsyren Ochirov <tsyren.hey@...>
everyone!
[#387853] Can I Safely Use Rubinius While Learning? — Aaron Jackson <jacksonaaronc@...>
Greetings,
On Thu, Sep 15, 2011 at 2:33 AM, Aaron Jackson <jacksonaaronc@gmail.com> wr=
Chris White wrote in post #1022049:
On Thu, Sep 15, 2011 at 10:43:23AM +0900, Aaron Jackson wrote:
[#387861] rake aborted! — "Ravi B." <ravibaswant.in@...>
Hi I am new to the ruby language in rhomobile application and when I
[#387878] Reading Stack Overflow RSS Feed — Samnang Chhun <samnang.chhun@...>
I would like to learn how to build a background running program that
[#387881] debug error in git commamd prompt — "Ravi B." <ravibaswant.in@...>
when i execute the $rake run:bb command it give error message
[#387906] Ruby On-line Courses — "Patil D." <patil.demerji@...>
I'm looking for recommendations for excellent ruby on-line courses or
[#387914] RVM + 1.9.3pre == broken readline — Chad Perrin <code@...>
I have not been able to get readline working with the 1.9.3 preview using
[#387915] Some newbie questions — Vladimir Van Bauenhoffer <cluny_gisslaren@...>
I got some newbie questions which I would very much appreciate if
[#387930] How long does it take to complete Ruby — Samuel Mensah <sasogeek@...>
Hi :)
[#387957] array.map! + delete_if possible ? — Kassym Dorsel <k.dorsel@...>
I have an array of strings that I need to modify. I either need to
On 17.09.2011 00:03, Kassym Dorsel wrote:
[#388001] opencv gem on snow leopard failing to bind to all required symbols — andrew mcelroy <sophrinix@...>
Greetings,
[#388003] Ruby Speed Question — Kevin Anon <oblivious.sage@...>
Wrote my first Ruby program recently for a class assignment where we had
On Sun, Sep 18, 2011 at 10:51 AM, Kevin Anon <oblivious.sage@gmail.com>wrote:
[#388006] download rvm and install later? — 7stud -- <bbxx789_05ss@...>
How do you download rvm without installing it?
On Sun, Sep 18, 2011 at 11:51 AM, 7stud -- <bbxx789_05ss@yahoo.com> wrote:
[#388013] Persistent storage in ruby — Lb Tr <treleven.lloyd@...>
Hi,
[#388017] FTP ports — Reese Chappuis <c0dege3k@...>
I've been writing a super simple terminal FTP client to send text files
maybe try using the connect method to manually specify the port number
[#388032] How-to run a 'minitest' test? — Lb Tr <treleven.lloyd@...>
Hi,
[#388044] — Асет Асет <asetpochta@...>
SGksCgpIb3cgdG8gZ2VuZXJhdGUgcmFuZCAocmFuZG9tIG51bWJlcikgYmV0d2VlbiB0d28gbnVt
[#388046] How to generate rand (random number) between two numbers? — Асет Асет <asetpochta@...>
SGksCgpIb3cgdG8gZ2VuZXJhdGUgcmFuZCAocmFuZG9tIG51bWJlcikgYmV0d2VlbiB0d28gbnVt
[#388049] Overloaded constructor — Aya Abdelsalam <ayoya_91@...>
Hello
[#388078] appending \n to each element in an array — Joe Collins <joec_49@...>
I have an array
On Tue, Sep 20, 2011 at 7:27 AM, Joe Collins <joec_49@hotmail.com> wrote:
[#388092] StringIO and encodings — Alex Young <alex@...>
This surprised me:
On Tue, Sep 20, 2011 at 4:18 PM, Alex Young <alex@blackkettle.org> wrote:
Adam Prescott wrote in post #1022947:
On Sep 20, 2011, at 8:32 AM, Alex Young wrote:
[#388097] Ruby on a Mac — Peter Bailey <pbailey@...>
HI,
[#388104] I am confused with installing a gem — "amir e." <aef1370@...>
Hi
[#388123] Turning on a special program at special time and turning off the computer at another special time — "amir e." <aef1370@...>
I decided to write a program in RUBY wherein these items have been done
That sounds like a program a special program a terrorist would write. Are
[#388135] flog 2.5.3 Released — Ryan Davis <ryand-ruby@...>
flog version 2.5.3 has been released!
[#388153] RegEx Help For checking alphnumeric — "Saurabh A." <getsauin@...>
Hi,
[#388164] Parsing xml with an any tag — abhishek asthana <abhishek813@...>
Hi,
[#388171] Ruby Help with HTML Form — "Mike M." <freemcg36@...>
I have html, css, and javascript background but have never touched Ruby.
[#388198] Conditional statements with multiple arguments — "Thomas B." <sinixlol@...>
Good afternoon everyone,
Peter,
I was thinking about this just yesterday. Sure would be nice if their
On Sun, Sep 25, 2011 at 7:10 AM, Intransition <transfire@gmail.com> wrote:
[#388203] Ruby 1.9.3 RC1 is out — "Yuki Sonoda (Yugui)" <yugui@...>
-----BEGIN PGP SIGNED MESSAGE-----
-----BEGIN PGP SIGNED MESSAGE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hello,
-----BEGIN PGP SIGNED MESSAGE-----
[Are there / will there be before final 1.9.3 release] any binary
Bartosz Dziewo=C5=84ski wrote in post #1023582:
2011/9/25 Jon Forums <jon.forums@gmail.com>:
Bartosz Dziewo=C5=84ski wrote in post #1024400:
[#388230] Distribute Ruby GUI App (Shoes) — "Maximilian S." <hisako1337@...>
Hi there!
This is the unfortunate current situation. Red shoes is the only one with a
@jake: I decided to post here because I also look for a general solution
[#388238] How about new syntax: "object.\method" returns a Method instance? — Joey Zhou <yimutang@...>
I'm afraid the normal way of creating a Method instance is circuitous
[#388241] FileUtils head-scratcher... — Chuck Remes <cremes.devlist@...>
In one of my projects I need to move all files and subdirectories in a particular directory up on level.
[#388248] Looking for better/familiar approach to command line opts — "Perl J." <perljunkie@...>
So I guess the warning to the reader upfront is... I'm a bit of a Perl
On Sun, Sep 25, 2011 at 3:48 PM, Perl J. <perljunkie@gmail.com> wrote:
On Sun, Sep 25, 2011 at 4:03 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
I'm not sure where that syntax for OptionParser came, and Trollop is a
David C. wrote in post #1023941:
[#388255] ffi-ncurses v0.4.0 released — "Sean O'Halpin" <sean.ohalpin@...>
Hi,
[#388261] problems with Benchmark on ruby 1.8.4 (rhe 5.3) — "Russell F." <russell.fulton@...>
Yes I know the version is ancient -- I'm stuck with it for various
On Mon, Sep 26, 2011 at 6:32 AM, Russell F. <russell.fulton@gmail.com> wrot=
[#388263] shoes-mocks 0.0.2 release — Steve Klabnik <steve@...>
shoes-mocks 0.0.2 has been released!
[#388264] shoes-cucumber 0.0.2 released! — Steve Klabnik <steve@...>
shoes-cucumber 0.0.2 has been released!
On Mon, Sep 26, 2011 at 02:38:25PM +0900, Steve Klabnik wrote:
Derp. I'll push up one a new one in a bit, but until then, like everything I
[#388309] ping sweep and threads — Panagiotis Atmatzidis <ml@...>
Dear Sir(s),
[#388312] got error: ERROR Errno::ECONNABORTED: An established connection was aborted by the software in your — "mohit b." <mohitbansal111@...>
Hi
[#388333] Get all classes from a list of files — Jeroen van Ingen <jeroeningen@...>
I have a list of ruby files. I would like to create objects from all
@Adam
On Sat, Oct 1, 2011 at 6:05 PM, Jeroen van Ingen <jeroeningen@gmail.com> wr=
[#388342] Ruby Syntax @keywords ||= [ ] — Bhavesh Sharma <sharmabhavesh@...>
Sorry if this comes across as a dumb question, but what does the
[#388354] Tree - Recursive print function — "Giacomo C." <lib.giacomo@...>
Hi There,
On Wed, Sep 28, 2011 at 8:30 PM, Chris White <cwprogram@live.com> wrote:
[#388363] What does "exit_on_fail("initialize") { hook('preinit') { preinit } } " mean? — Yunfeng Xu <hywl51@...>
Hi,
[#388366] IO.readlines will not accept variable with file name Why? — Joda jenson <jodajen2@...>
I am fairly new to Ruby and I am stuck on this. Would someone have a
On Thu, Sep 29, 2011 at 11:14 AM, Joda jenson <jodajen2@yahoo.com> wrote:
On Thu, Sep 29, 2011 at 11:56 AM, Robert Klemme
Robert Klemme wrote in post #1024202:
On Thu, Sep 29, 2011 at 10:39 PM, Joda jenson <jodajen2@yahoo.com> wrote:
Peter Vandenabeele wrote in post #1024266:
On Thu, Sep 29, 2011 at 11:20 PM, Joda jenson <jodajen2@yahoo.com> wrote:
[#388381] Variables, Arrays and Hashes. — "Rob V." <robtvogel@...>
I'm trying to make a card game with Ruby. I created a hash of cards and
On Thu, Sep 29, 2011 at 8:40 PM, Rob V. <robtvogel@gmail.com> wrote:
"Jes=C3=BAs Gabriel y Gal=C3=A1n" <jgabrielygalan@gmail.com> wrote in pos=
On Thu, Sep 29, 2011 at 8:54 PM, Rob V. <robtvogel@gmail.com> wrote:
[#388397] simple program, need help — Trevor Harker <koolaidmancometh@...>
File attached.
[#388406] using alias_method before function definition — Reginald Tan <redge.tan@...>
Hi guys, I'm having problems with using alias_method. When i run this
[#388414] How to write a text in red color — Sat nosur <skoppu123@...>
Hi All,
[#388418] RVM seems to fail — Stavros Kefaleas <skiabox12@...>
I have already installed ruby 1.8.7 by default in my system (macos
[#388429] Problem with Ruby 1.9.3 RC1 and YAML files — Marc Heiler <shevegen@...>
I am trying to get ruby 1.9.3 rc1 to work and it fails because of my
Re: Looking for better/familiar approach to command line opts
On Sun, Sep 25, 2011 at 3:48 PM, Perl J. <perljunkie@gmail.com> wrote:
> So I guess the warning to the reader upfront is... I'm a bit of a Perl
> hack who should have moved to Ruby a decade ago and just couldn't let go
> of Perl. Perl still does stuff that I use extensively that I can't
> (take the time to) figure out how to do in Ruby, so... that's why I'm
> here.
>
> I've got a small framework I wrote in Perl I've been using for years
> that is lightweight and yet powerful. A lot of it centers around the
> use of AUTOLOAD, which some Perlers say is bad -- I say it's extremely
> powerful if used properly, and actually, AUTOLOAD forms a lot of the
> backbone for my framework. And honestly, it's helped me do some things
> in Perl that I see in Ruby. So there's some irony here in that I wrote
> a framework to give me some of the power I see in Ruby in Perl. :-)
>
> With all that as a backdrop, here's how I can process command line
> arguments in Perl (*everything* I do in Perl is OO!!) and I want the
> same thing in Ruby. OptParser in Ruby is WAY more than I'm looking for
> -- not as easy as what I'm used to (or maybe I don't understand
> OptParser, which is likely).
>
> In Perl, I can do this:
>
> options = MyFramework::Options->new(
> sourcePath => 's:'
> destPath => 'd:'
> verbose => 'v'
> );
>
> What ends up happening behind the scenes is a class instance is created
> dynamically that essentially gives me the ability to say:
>
> ## I actually have a puts() I created in Perl as well,
> ## borrowed from Ruby!
> puts(
> "Source path.......: " . $options->sourcePath,
> "Destination path..: " . $options->destPath,
> "Verbose is........: " . ($options->verbose ? 'ON' : 'OFF'),
> );
>
> So I have a getter for sourcePath, a getter for destPath and a getter
> for verbose, automagically created for that instance loaded with the
> values from the command line. If I said:
>
> whatever = MyFramework::Options->new(
> foo => 'f:',
> bar => 'b:',
> );
>
> Then I would have an instance of 'whatever' with foo and bar as getters,
> etc. with the values of 'f' and 'b' from the command line loaded
> appropriately.
>
> Now how to do this in Ruby? Like I said, the OptParser seems WAY too
> complicated for what I want and am trying to do. It seems like you
> still are coding some kind of OptParser class for the specific options
> you want -- I don't want to create classes that mirror the command line
> options. I want to tell the class instance at the time I create it
> (kind of like OpenStruct) what it looks like and it just creates the
> right instance. I want to be able to do this in Ruby, assuming I would
> "define" this dynamically on the fly using maybe a hash as initial
> input... I like the flexibility of hashes:
>
> options = Options.new({
> :sPath => 's:',
> :dPath => 'd:',
> :verbose => 'v',
> })
>
> puts "Source path.......: #{options.sPath}"
> puts "Destination path..: #{options.dPath}"
> puts "Verbose is........: #{options.verbose ? 'ON' : 'OFF'}"
>
> What this is saying is "map the value of 's' from the command line into
> @sPath, map the value of 'd' from the command line into @dPath, and map
> whether 'v' exists, true or false, into @verbose." Now how much more
> simple can you get??!!
>
> Again, the warning of "trying to do Ruby stuff in a Perl way" comes to
> me, but what I do in Perl is so stinking simple, it's unbelievable, and
> this is one reason I haven't switched over to Ruby yet. But now I'm
> trying.
>
> Things I've tried: A lot of different combinations of...
> -- missing_method()
> -- define_method()
> (I don't understand why a lot of d_m() examples use self.class.send()!!)
> -- Struct()
> -- OpenStruct()
>
> So far, requiring "optparse" and doing ARGV.getopts() does some of what
> I want. This is as close as I've gotten and it's not working:
>
> require "optparse"
>
> class Options
> attr_reader :cmdline, :options_list
> def initialize( options )
> @cmdline = ARGV.join( ' ' )
> @options_list = options.values.join
> params = ARGV.getopts( @options_list )
> options.each do |key,value|
> ## Why do I need to send( :define_method, ... ) here?
> ## Why can't I just say self.define_method?
> ## This seems like it would create proper closure
> ## on params[] elements?!
> self.class.send( :define_method, key ) { params[value] }
> end
> end
> end
>
> options = Options.new({
> :sPath => 's:',
> :dPath => 'd:',
> :verbose => 'v',
> })
>
> If someone can tell me how to do this using OptParser, so be it. But
> from an encapsulation standpoint, I'd like to be able to call it as I do
> above. If the innards of the Options class use OptParser, fine.
>
> -pj
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Ruby has a builtin -s flag, which will parse args
I don't know Perl so I can't say if it will meet your needs, but does this
program do what you want?
-----
#!/usr/bin/env ruby -s
options = {
:source_path => 's'
:dest_path => 'd'
:verbose => 'v'
}
p options