Skip to content

Instantly share code, notes, and snippets.

Created November 14, 2016 21:02
Show Gist options
  • Save anonymous/e8d615b73aa2c10ffba78917f2013e68 to your computer and use it in GitHub Desktop.
Save anonymous/e8d615b73aa2c10ffba78917f2013e68 to your computer and use it in GitHub Desktop.
# [4] pry(main)> Ripper.sexp('nil unless ip == "localhost" or ip.include? "."')
[:program,
[[:unless_mod,
[:binary,
[:binary,
[:vcall, [:@ident, "ip", [1, 11]]],
:==,
[:string_literal,
[:string_content, [:@tstring_content, "localhost", [1, 18]]]]],
:or,
[:command_call,
[:vcall, [:@ident, "ip", [1, 32]]],
:".",
[:@ident, "include?", [1, 35]],
[:args_add_block,
[[:string_literal,
[:string_content, [:@tstring_content, ".", [1, 45]]]]],
false]]],
[:var_ref, [:@kw, "nil", [1, 0]]]]]]
# [5] pry(main)> Ripper.sexp('nil unless ip == "localhost" || ip.include?(".")')
[:program,
[[:unless_mod,
[:binary,
[:binary,
[:vcall, [:@ident, "ip", [1, 11]]],
:==,
[:string_literal,
[:string_content, [:@tstring_content, "localhost", [1, 18]]]]],
:"||",
[:method_add_arg,
[:call,
[:vcall, [:@ident, "ip", [1, 32]]],
:".",
[:@ident, "include?", [1, 35]]],
[:arg_paren,
[:args_add_block,
[[:string_literal,
[:string_content, [:@tstring_content, ".", [1, 45]]]]],
false]]]],
[:var_ref, [:@kw, "nil", [1, 0]]]]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment