D
Donkey Agony
The chapter in the Pickaxe 2nd ed. on irb gives some code for using `ri`
from within it:
def ri(*names)
system(%{ri #(*names.map {|name| name.to_s}.join(" ")}})
end
But that throws an error here. I'm just getting started with Ruby, so I
don't quite understand yet why you have to go through all that
rigamarole just to pass a parameter to `system 'ri keyword'`, nor what
exactly the rigamarole does , but looking at it I can see there's an
unmatched closing curly brace before the final parens. So I changed it
to:
def ri(*names)
system(%{ri #(*names.map {|name| name.to_s}.join(" ")})
end
I tried it from within irb as "ri Proc" both in Cygwin and plain
Windows. It caused the Cygwin version to core dump (!), and the Windows
version to return this:
'name' is not recognized as an internal or external command,
operable program or batch file.
=> false
So what is proper way to write that method so I can invoke `ri` from
within irb?
Also, what is the % sign for in the `system` command above?
from within it:
def ri(*names)
system(%{ri #(*names.map {|name| name.to_s}.join(" ")}})
end
But that throws an error here. I'm just getting started with Ruby, so I
don't quite understand yet why you have to go through all that
rigamarole just to pass a parameter to `system 'ri keyword'`, nor what
exactly the rigamarole does , but looking at it I can see there's an
unmatched closing curly brace before the final parens. So I changed it
to:
def ri(*names)
system(%{ri #(*names.map {|name| name.to_s}.join(" ")})
end
I tried it from within irb as "ri Proc" both in Cygwin and plain
Windows. It caused the Cygwin version to core dump (!), and the Windows
version to return this:
'name' is not recognized as an internal or external command,
operable program or batch file.
=> false
So what is proper way to write that method so I can invoke `ri` from
within irb?
Also, what is the % sign for in the `system` command above?