Class: UnboundMethod
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #arity ⇒ Object
- #bind(object) ⇒ Object
- #comments ⇒ Object
-
#initialize(source, owner, method, name) ⇒ UnboundMethod
constructor
A new instance of UnboundMethod.
- #inspect ⇒ Object
- #parameters ⇒ Object
- #source_location ⇒ Object
Constructor Details
#initialize(source, owner, method, name) ⇒ UnboundMethod
Returns a new instance of UnboundMethod.
60 61 62 63 64 65 |
# File 'opal/opal/corelib/method.rb', line 60 def initialize(source, owner, method, name) @source = source @owner = owner @method = method @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
58 59 60 |
# File 'opal/opal/corelib/method.rb', line 58 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
58 59 60 |
# File 'opal/opal/corelib/method.rb', line 58 def owner @owner end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
58 59 60 |
# File 'opal/opal/corelib/method.rb', line 58 def source @source end |
Instance Method Details
#arity ⇒ Object
67 68 69 |
# File 'opal/opal/corelib/method.rb', line 67 def arity @method.arity end |
#bind(object) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'opal/opal/corelib/method.rb', line 83 def bind(object) %x{ if (#{@owner}.$$is_module || Opal.is_a(#{object}, #{@owner})) { return #{Method.new(object, @owner, @method, @name)}; } else { #{raise TypeError, "can't bind singleton method to a different class (expected #{object}.kind_of?(#{@owner} to be true)"}; } } end |
#comments ⇒ Object
79 80 81 |
# File 'opal/opal/corelib/method.rb', line 79 def comments `#{@method}.$$comments` || [] end |
#inspect ⇒ Object
94 95 96 |
# File 'opal/opal/corelib/method.rb', line 94 def inspect "#<#{self.class}: #{@source}##{@name} (defined in #{@owner} in #{source_location.join(':')})>" end |
#parameters ⇒ Object
71 72 73 |
# File 'opal/opal/corelib/method.rb', line 71 def parameters `#{@method}.$$parameters` end |
#source_location ⇒ Object
75 76 77 |
# File 'opal/opal/corelib/method.rb', line 75 def source_location `#{@method}.$$source_location` || ['(eval)', 0] end |