Class: Method
- Inherits:
-
Object
- Object
- Method
- Defined in:
- opal/opal/corelib/method.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Instance Method Summary collapse
- #arity ⇒ Object
- #call(*args, &block) ⇒ Object (also: #[])
-
#initialize(receiver, method, name) ⇒ Method
constructor
A new instance of Method.
- #inspect ⇒ Object
- #to_proc ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(receiver, method, name) ⇒ Method
Returns a new instance of Method
4 5 6 7 8 9 |
# File 'opal/opal/corelib/method.rb', line 4 def initialize(receiver, method, name) @receiver = receiver @owner = receiver.class @name = name @method = method end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
2 3 4 |
# File 'opal/opal/corelib/method.rb', line 2 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner
2 3 4 |
# File 'opal/opal/corelib/method.rb', line 2 def owner @owner end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver
2 3 4 |
# File 'opal/opal/corelib/method.rb', line 2 def receiver @receiver end |
Instance Method Details
#arity ⇒ Object
11 12 13 |
# File 'opal/opal/corelib/method.rb', line 11 def arity @method.arity end |
#call(*args, &block) ⇒ Object Also known as: []
15 16 17 18 19 20 21 |
# File 'opal/opal/corelib/method.rb', line 15 def call(*args, &block) %x{ #@method._p = block; return #@method.apply(#@receiver, args); } end |
#inspect ⇒ Object
33 34 35 |
# File 'opal/opal/corelib/method.rb', line 33 def inspect "#<Method: #{@obj.class.name}##@name}>" end |
#to_proc ⇒ Object
29 30 31 |
# File 'opal/opal/corelib/method.rb', line 29 def to_proc @method end |
#unbind ⇒ Object
25 26 27 |
# File 'opal/opal/corelib/method.rb', line 25 def unbind UnboundMethod.new(@owner, @method, @name) end |