JoshCheek / seeing_is_believing

Displays the results of every line of code in your file
1.3k stars 54 forks source link

Endless method support #158

Open JoshCheek opened 3 years ago

JoshCheek commented 3 years ago
RUBY_VERSION # => "3.0.0"

require 'parser/current'
sexp = Parser::CurrentRuby.parse <<~RUBY
def omg = 123

def wat
  123
end
RUBY

one, three = sexp.children
# => [s(:def, :omg,
#      s(:args),
#      s(:int, 123)),
#     s(:def, :wat,
#      s(:args),
#      s(:int, 123))]

one.loc.assignment    # => #<Parser::Source::Range (string) 8...9>
one.loc.end           # => nil

three.loc.assignment  # => nil
three.loc.end         # => #<Parser::Source::Range (string) 29...32>