Class: TheoryVariable

Inherits:
Object show all
Includes:
Token, Variable
Defined in:
lib/theory/TheoryVariable.rb

Constant Summary collapse

RED =
"\033[31m"
GREEN =
"\033[32m"
YELLOW =
"\033[33m"
TURQUOISE =
"\033[34m"
VIOLET =
"\033[35m"
BLUE =
"\033[36m"
NORMAL =
"\033[m"

Instance Attribute Summary collapse

Attributes included from Variable

#scope_id, #uniq_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Variable

#increament_uniq_id!, #meets_requirements?, reset_global_id, #to_var, variable_id

Methods included from VariableIncluded

#find_actual_variable, #variable

Constructor Details

#initialize(theory_variable_id) ⇒ TheoryVariable

Returns a new instance of TheoryVariable.



15
16
17
# File 'lib/theory/TheoryVariable.rb', line 15

def initialize(theory_variable_id)
  @theory_variable_id = theory_variable_id
end

Instance Attribute Details

#theory_variable_idObject (readonly)

Returns the value of attribute theory_variable_id.



5
6
7
# File 'lib/theory/TheoryVariable.rb', line 5

def theory_variable_id
  @theory_variable_id
end

Class Method Details

.variable_colour(theory_variable_id) ⇒ Object

Returns the preset colour for that particular id for easier tracking.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/theory/TheoryVariable.rb', line 46

def self.variable_colour(theory_variable_id)
  case theory_variable_id
    when 0
      return RED
    when 1
      return GREEN
    when 2
      return YELLOW
    when 3
      return TURQUOISE  
    when 4
      return VIOLET
  else
      return BLUE
  end
end

Instance Method Details

#copyObject



27
28
29
# File 'lib/theory/TheoryVariable.rb', line 27

def copy
  return TheoryVariable.new(@theory_variable_id.copy)    
end

#describeObject



23
24
25
# File 'lib/theory/TheoryVariable.rb', line 23

def describe
  return TheoryVariable.variable_colour(@theory_variable_id)+"var#{@theory_variable_id}"+NORMAL    
end

#eql?(obj) ⇒ Boolean

Returns:



35
36
37
# File 'lib/theory/TheoryVariable.rb', line 35

def eql?(obj)
  @theory_variable_id == obj.theory_variable_id     
end

#hashObject



39
40
41
# File 'lib/theory/TheoryVariable.rb', line 39

def hash
  @theory_variable_id
end

#to_declarationObject



31
32
33
# File 'lib/theory/TheoryVariable.rb', line 31

def to_declaration
  return VariableDeclaration.new('TheoryVariable',Literal.new(@theory_variable_id).to_declaration)
end

#writeObject



19
20
21
# File 'lib/theory/TheoryVariable.rb', line 19

def write
  return "var#{@theory_variable_id}"
end