Class: DefCall
- Inherits:
-
InstanceCall
- Object
- Array
- InstanceCall
- DefCall
- Includes:
- WriteParameters
- Defined in:
- lib/core/method_call/DefCall.rb
Overview
This class represent calls to availble functions. This could be custom generated method calls e.g.
m1
if there was a method that looked like
def m1
# do something
end
it could also be core ruby calls
TODO Write tests for this
Instance Attribute Summary collapse
-
#runtime_method ⇒ Object
readonly
TODO I’m still undecided on whether DefCall should have a scope id or not.
-
#scope_id ⇒ Object
TODO I’m still undecided on whether DefCall should have a scope id or not.
Instance Method Summary collapse
- #copy ⇒ Object
- #describe ⇒ Object
- #equivalent?(to) ⇒ Boolean
-
#initialize(response, runtime_method, *parameters) ⇒ DefCall
constructor
TODO I suspect response isn’t needed any more or at least should be the secound parameter.
-
#pass_as?(variable_type) ⇒ Boolean
Returns true if the method call can pass as specified variable_type.
- #response ⇒ Object
- #write ⇒ Object
Methods included from WriteParameters
#describe_params, #write_params
Methods inherited from InstanceCall
#closure, #destructive?, #requirements, #to_declaration, #to_literal_string, #use, #valid_syntax?
Methods inherited from Array
#cauldron_method_calls, #contains?, #select_all, #to_declaration, #to_intrinsic, #to_literal, #to_var
Constructor Details
#initialize(response, runtime_method, *parameters) ⇒ DefCall
TODO I suspect response isn’t needed any more or at least should be the secound parameter
27 28 29 30 31 32 33 |
# File 'lib/core/method_call/DefCall.rb', line 27 def initialize(response,runtime_method,*parameters) super(*parameters) raise StandardError.new('Should be a runtime method instance') unless runtime_method.kind_of?(ActsAsRuntimeMethod) @response = response.copy @runtime_method = runtime_method.copy end |
Instance Attribute Details
#runtime_method ⇒ Object (readonly)
TODO I’m still undecided on whether DefCall should have a scope id or not
20 21 22 |
# File 'lib/core/method_call/DefCall.rb', line 20 def runtime_method @runtime_method end |
#scope_id ⇒ Object
TODO I’m still undecided on whether DefCall should have a scope id or not
20 21 22 |
# File 'lib/core/method_call/DefCall.rb', line 20 def scope_id @scope_id end |
Instance Method Details
#copy ⇒ Object
46 47 48 |
# File 'lib/core/method_call/DefCall.rb', line 46 def copy return DefCall.new(@response.copy,@runtime_method.copy,*self.collect {|x| x.copy}) end |
#describe ⇒ Object
41 42 43 44 |
# File 'lib/core/method_call/DefCall.rb', line 41 def describe x = 'Call: '+write return x end |
#equivalent?(to) ⇒ Boolean
64 65 66 67 68 69 70 |
# File 'lib/core/method_call/DefCall.rb', line 64 def equivalent?(to) return false unless to.class == self.class # TODO I should also include a method_interation value here - this should increment each time the # the runtime method recieves a new statement because it essentially becomes a different method. return true if @runtime_method.method_id == to.runtime_method.method_id return false end |
#pass_as?(variable_type) ⇒ Boolean
Returns true if the method call can pass as specified variable_type. This bascially depends on what the method call returns.
60 61 62 |
# File 'lib/core/method_call/DefCall.rb', line 60 def pass_as?(variable_type) return @response.pass_as?(variable_type) end |
#response ⇒ Object
50 51 52 |
# File 'lib/core/method_call/DefCall.rb', line 50 def response return @response.copy end |
#write ⇒ Object
35 36 37 38 39 |
# File 'lib/core/method_call/DefCall.rb', line 35 def write l = @runtime_method.method_name l += write_params(self) return l end |