Skip to content

Commit

Permalink
Implement minimal #inspect method support
Browse files Browse the repository at this point in the history
  • Loading branch information
elct9620 committed Sep 12, 2024
1 parent abf0af4 commit 78a5457
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions features/object.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ Feature: Object
Hello.new.world
"""
Then there should return string "world"

Scenario: I can new a object
When I execute ruby code:
"""
Object.inspect
"""
Then there should return string "Object"
12 changes: 11 additions & 1 deletion kernel.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package mruby

func objectInspect(mrb *State, self Value) Value {
return nil
switch v := self.(type) {
case *Object:
return "Object"
case *Class:
name := mrb.ObjectInstanceVariableGet(v, _classname(mrb))
return name
case *Module:
return "Module"
default:
return nil
}
}

func initKernel(mrb *State) (err error) {
Expand Down

0 comments on commit 78a5457

Please sign in to comment.