Slide 58
Slide 58 text
@chrisarcand chrisarcand.com
class Person
def greet(name)
puts "Hello #{name}!"
end
end
person = Person.new
person.greet("RubyKaigi")
> parser = RubyParser.for_current_ruby
> parser.parse(File.read(“example1.rb”))
1 s(:block,
2 s(:class, :Person, nil,
3 s(:defn, :greet, s(:args, :name),
4 s(:call, nil, :puts,
5 s(:dstr, "Hello ", s(:evstr, s(:lvar, :name)), s(:str, "!"))))),
6 s(:lasgn, :person, s(:call, s(:const, :Person), :new)),
7 s(:call, s(:lvar, :person), :greet, s(:str, "RubyKaigi")))
example1.rb