Forum: Ruby Extract all case when entries

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7e17d370dc95b48cd82944a62f1caf76?d=identicon&s=25 Robert H. (shevegen)
on 2014-07-20 16:29


def foo(i)
  case i
  when 'foo','bar',
  when 'yo'

Is there a simple way to programmatically get all entries of a given
case menu?

So I would get an array like:


9627ec27e4fb3a18be02133b4ddaa901?d=identicon&s=25 Joel P. (virtuoso)
on 2014-07-20 19:03
The only way I could think of to do that would be to read and parse the
text file containing the code. Then it's a bit of regex to isolate the
case statement and pull out the entries.
This topic is locked and can not be replied to.