Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created February 8, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/c1b754cf58f134ac1ce322b484d8363a to your computer and use it in GitHub Desktop.
Save havenwood/c1b754cf58f134ac1ce322b484d8363a to your computer and use it in GitHub Desktop.
PARSING_ROUTES = [
{meth: :name, regexp: %r{\A\$((::)?(\w+(-\w+)*::)*\w+(-\w+)*(\[.+?\])*)}, first: true},
{meth: :content, regexp: %r{\A'.*?'}m},
# ...
]
route = PARSING_ROUTES.find { |regexp:| chunk =~ regexp }
params = route.slice(:first, :possible_regexp_check).compact
public_send(route.fetch(:method), params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment