Class: ToyLangObject
- Inherits:
-
Object
- Object
- ToyLangObject
- Defined in:
- lib/toylang/runtime/object.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ruby_value ⇒ Object
Returns the value of attribute ruby_value.
-
#runtime_class ⇒ Object
Returns the value of attribute runtime_class.
Instance Method Summary collapse
- #call(method, arguments = []) ⇒ Object
-
#initialize(runtime_class, ruby_value = self) ⇒ ToyLangObject
constructor
A new instance of ToyLangObject.
- #inspect ⇒ Object
Constructor Details
#initialize(runtime_class, ruby_value = self) ⇒ ToyLangObject
Returns a new instance of ToyLangObject.
6 7 8 9 |
# File 'lib/toylang/runtime/object.rb', line 6 def initialize(runtime_class, ruby_value = self) @runtime_class = runtime_class @ruby_value = ruby_value end |
Instance Attribute Details
#ruby_value ⇒ Object
Returns the value of attribute ruby_value.
4 5 6 |
# File 'lib/toylang/runtime/object.rb', line 4 def ruby_value @ruby_value end |
#runtime_class ⇒ Object
Returns the value of attribute runtime_class.
4 5 6 |
# File 'lib/toylang/runtime/object.rb', line 4 def runtime_class @runtime_class end |
Instance Method Details
#call(method, arguments = []) ⇒ Object
11 12 13 |
# File 'lib/toylang/runtime/object.rb', line 11 def call(method, arguments = []) @runtime_class.lookup(method).call(self, arguments) end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/toylang/runtime/object.rb', line 15 def inspect "#<ToyLangObject class=#{@runtime_class} ruby_value=#{@ruby_value}" end |