Class: This

Inherits:
Array show all
Defined in:
lib/core/syntax/This.rb

Overview

Not sure how or is this class will be used but it is meant as contextual reference to a different instance.

TODO Check whether this needs to be an array

Instance Method Summary collapse

Methods inherited from Array

#cauldron_method_calls, #contains?, #select_all, #to_declaration, #to_intrinsic, #to_literal, #to_var

Constructor Details

#initialize(*parameters) ⇒ This

Returns a new instance of This.

Parameters:

  • method_call

    The name of any method call if any. For example: self.class



12
13
14
15
16
17
# File 'lib/core/syntax/This.rb', line 12

def initialize(*parameters)
  super()
  
  # Save any requirements
  parameters.collect {|param| self.push param}
end

Instance Method Details

#copyObject



32
33
34
# File 'lib/core/syntax/This.rb', line 32

def copy
  return This.new
end

#declaration_statementObject



36
37
38
# File 'lib/core/syntax/This.rb', line 36

def declaration_statement
  return ClassMethodCallContainer.new(ThisClass.new,New.new)
end

#describe(context = nil, variable = nil) ⇒ Object



28
29
30
# File 'lib/core/syntax/This.rb', line 28

def describe(context=nil,variable=nil)
  return write(context,variable)+"\n"
end

#write(context = nil, variable = nil) ⇒ Object

Parameters:

  • variable (defaults to: nil)

    The variable “self” refers to. This is dependent on where the instance is used.



22
23
24
25
26
# File 'lib/core/syntax/This.rb', line 22

def write(context=nil,variable=nil)
  if context.nil? then return 'self' end
  if variable.nil? then return 'self' end            
  return context.display_name_for(variable)
end