Class: Method
- Defined in:
- opal/opal/corelib/method.rb,
opal/opal/corelib/marshal/write_buffer.rb
Overview
backtick_javascript: true
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
- #<<(other) ⇒ Object
- #>>(other) ⇒ Object
- #__marshal__(buffer) ⇒ Object
- #arity ⇒ Object
- #call(*args, &block) ⇒ Object (also: #[], #===)
- #comments ⇒ Object
- #curry(arity = undefined) ⇒ Object
-
#initialize(receiver, owner, method, name) ⇒ Method
constructor
A new instance of Method.
- #inspect ⇒ Object
- #parameters ⇒ Object
- #source_location ⇒ Object
- #to_proc ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(receiver, owner, method, name) ⇒ Method
Returns a new instance of Method.
6 7 8 9 10 11 |
# File 'opal/opal/corelib/method.rb', line 6 def initialize(receiver, owner, method, name) @receiver = receiver @owner = owner @name = name @method = method end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'opal/opal/corelib/method.rb', line 4 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
4 5 6 |
# File 'opal/opal/corelib/method.rb', line 4 def owner @owner end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
4 5 6 |
# File 'opal/opal/corelib/method.rb', line 4 def receiver @receiver end |
Instance Method Details
#<<(other) ⇒ Object
45 46 47 |
# File 'opal/opal/corelib/method.rb', line 45 def <<(other) @method << other end |
#>>(other) ⇒ Object
41 42 43 |
# File 'opal/opal/corelib/method.rb', line 41 def >>(other) @method >> other end |
#__marshal__(buffer) ⇒ Object
103 104 105 |
# File 'opal/opal/corelib/marshal/write_buffer.rb', line 103 def __marshal__(buffer) ::Kernel.raise ::TypeError, "no _dump_data is defined for class #{self.class}" end |
#arity ⇒ Object
13 14 15 |
# File 'opal/opal/corelib/method.rb', line 13 def arity @method.arity end |
#call(*args, &block) ⇒ Object Also known as: [], ===
29 30 31 32 33 34 35 |
# File 'opal/opal/corelib/method.rb', line 29 def call(*args, &block) %x{ #{@method}.$$p = block; return #{@method}.apply(#{@receiver}, args); } end |
#comments ⇒ Object
25 26 27 |
# File 'opal/opal/corelib/method.rb', line 25 def comments `#{@method}.$$comments` || [] end |
#curry(arity = undefined) ⇒ Object
37 38 39 |
# File 'opal/opal/corelib/method.rb', line 37 def curry(arity = undefined) @method.curry(arity) end |
#inspect ⇒ Object
64 65 66 |
# File 'opal/opal/corelib/method.rb', line 64 def inspect "#<#{self.class}: #{@receiver.class}##{@name} (defined in #{@owner} in #{source_location.join(':')})>" end |
#parameters ⇒ Object
17 18 19 |
# File 'opal/opal/corelib/method.rb', line 17 def parameters `#{@method}.$$parameters` end |
#source_location ⇒ Object
21 22 23 |
# File 'opal/opal/corelib/method.rb', line 21 def source_location `#{@method}.$$source_location` || ['(eval)', 0] end |
#to_proc ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'opal/opal/corelib/method.rb', line 53 def to_proc %x{ var proc = self.$call.bind(self); proc.$$unbound = #{@method}; proc.$$is_lambda = true; proc.$$arity = #{@method}.$$arity == null ? #{@method}.length : #{@method}.$$arity; proc.$$parameters = #{@method}.$$parameters; return proc; } end |
#unbind ⇒ Object
49 50 51 |
# File 'opal/opal/corelib/method.rb', line 49 def unbind ::UnboundMethod.new(@receiver.class, @owner, @method, @name) end |