Class: MethodUsageVariable
- Inherits:
-
BaseVariable
- Object
- Array
- BaseVariable
- MethodUsageVariable
- Defined in:
- lib/core/variable/MethodUsageVariable.rb
Instance Attribute Summary
Attributes inherited from BaseVariable
#instance_variable, #uniq_id_history, #value, #variable_id
Attributes included from Variable
Instance Method Summary collapse
- #copy ⇒ Object
- #destructive_instance_calls(with = []) ⇒ Object
-
#equivalent?(to) ⇒ Boolean
TODO Write tests Compares the passed argument and returns true if they are the same class and contains the same values.
-
#initialize(*parameters) ⇒ MethodUsageVariable
constructor
A new instance of MethodUsageVariable.
- #to_declaration ⇒ Object
-
#to_literal_string ⇒ Object
TODO Test this.
Methods inherited from BaseVariable
#find_actual_variable, #instance_calls, #realised?, reset_global_id, #returning_instance_calls, #write, #write_with_uniq_id
Methods included from Variable
#increament_uniq_id!, #meets_requirements?, reset_global_id, #to_var, variable_id
Methods included from VariableIncluded
#find_actual_variable, #variable
Methods inherited from Array
#cauldron_method_calls, #contains?, #select_all, #to_intrinsic, #to_literal, #to_var, #write
Constructor Details
#initialize(*parameters) ⇒ MethodUsageVariable
Returns a new instance of MethodUsageVariable.
3 4 5 6 7 8 9 10 11 |
# File 'lib/core/variable/MethodUsageVariable.rb', line 3 def initialize(*parameters) super() raise StandardError.new('Only submit the paramaters on the usage variable') if parameters.first.kind_of?(MethodUsage) # Go through each paramater in the method usage instance parameters.each do |x| self.push x.copy end end |
Instance Method Details
#copy ⇒ Object
17 18 19 20 |
# File 'lib/core/variable/MethodUsageVariable.rb', line 17 def copy result = MethodUsageVariable.new(*self.collect {|x| x.copy}) {{:variable_id => self.variable_id,:uniq_id=>@uniq_id, :uniq_id_history=>@uniq_id_history.copy}} return result end |
#destructive_instance_calls(with = []) ⇒ Object
56 57 58 |
# File 'lib/core/variable/MethodUsageVariable.rb', line 56 def destructive_instance_calls(with=[]) return [] end |
#equivalent?(to) ⇒ Boolean
TODO Write tests Compares the passed argument and returns true if they are the same class and contains the same values.
48 49 50 51 52 53 54 |
# File 'lib/core/variable/MethodUsageVariable.rb', line 48 def equivalent?(to) return false if to.class != self.class to.zip(self) do |x,y| return false unless x.equivalent?(y) end return true end |
#to_declaration ⇒ Object
13 14 15 |
# File 'lib/core/variable/MethodUsageVariable.rb', line 13 def to_declaration return VariableDeclaration.new('MethodUsageVariable',*self.collect {|x| x.to_declaration}) end |
#to_literal_string ⇒ Object
TODO Test this
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/core/variable/MethodUsageVariable.rb', line 32 def to_literal_string l = 'MethodUsage.new(' self.each do |x| l += x.to_literal_string unless x.object_id == self.last.object_id l += ',' end end l += ')' return l end |