ahh, I think that just might work! the method also has a default value for
if no number is given and that won't account for that, but i can just say:
  when /^SEEKF (\d+)$/, "SEEKF"
and maybe add a little logic to only display $1 if it's not equal to 0
otherwise display 3 (which is the default value).

I'm guessing there might be a way to do that by changing that regexp a
little bit, but I'm truly horrible with regexp, lol
thank you very much!

On Mon, Nov 28, 2016 at 4:13 PM, Matthew Kerwin <matthew / kerwin.net.au>
wrote:

>
>
> On 29 November 2016 at 09:56, Micky Scandal <mickyscandal / gmail.com>
> wrote:
>
>> hello, question. I don't know if this is even possible but is there a way
>> to give arguments in a case statement? I currently have something like this:
>>
>>       def seek_foreward(amt = 3)
>>         @player.seek(amt)
>>       end
>>
>>       when "SEEKF"
>>         puts "Enter amount to seek forward: "
>>         amt = STDIN.gets.chomp
>>         player.seek_foreward(amt)
>>
>> but what I was hoping for is to be able to input something like this:
>>  :> SEEKF 10
>> and have it give 10 to the seek_foreward method. is something like that
>> possible with a case statement? or is there another way to implement this?
>>
>
> Do you mean you want to be able to match a string that starts with 'SEEKF'
> in the `when` clause? Regular expressions might help:
>
> ~~~
> irb(main):001:0> case STDIN.gets.chomp
> irb(main):002:1> when /^SEEKF (\d+)$/
> irb(main):003:1>   puts ">>> SEEKING #{$1.to_i}"
> irb(main):004:1> else
> irb(main):005:1*   puts "???"
> irb(main):006:1> end
> SEEKF 10
> >>> SEEKING 10
> ~~~
>
> Cheers
> --
>   Matthew Kerwin
>   http://matthew.kerwin.net.au/
>
>
> Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>
>
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>