class SyntaxTree::YARV::DefineMethod
### Summary
‘definemethod` defines a method on the class of the current value of `self`. It accepts two arguments. The first is the name of the method being defined. The second is the instruction sequence representing the body of the method.
### Usage
~~~ruby def value = “value” ~~~
Attributes
Public Class Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1124 def initialize(method_name, method_iseq) @method_name = method_name @method_iseq = method_iseq end
Public Instance Methods
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1145 def ==(other) other.is_a?(DefineMethod) && other.method_name == method_name && other.method_iseq == method_iseq end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1154 def call(vm) name = method_name nesting = vm.frame.nesting iseq = method_iseq vm .frame ._self .__send__(:define_method, name) do |*args, **kwargs, &block| vm.run_method_frame( name, nesting, iseq, self, *args, **kwargs, &block ) end end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1141 def deconstruct_keys(_keys) { method_name: method_name, method_iseq: method_iseq } end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1129 def disasm(fmt) fmt.enqueue(method_iseq) fmt.instruction( "definemethod", [fmt.object(method_name), method_iseq.name] ) end
Source
# File lib/syntax_tree/yarv/instructions.rb, line 1137 def to_a(_iseq) [:definemethod, method_name, method_iseq.to_a] end