Class: Nudge::ReferencePoint

Inherits:
ProgramPoint show all
Defined in:
lib/interpreter/programPoints.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ProgramPoint

#each

Constructor Details

#initialize(var_name) ⇒ ReferencePoint

Returns a new instance of ReferencePoint.



164
165
166
# File 'lib/interpreter/programPoints.rb', line 164

def initialize(var_name)
  @name = var_name
end

Instance Attribute Details

#nameObject Also known as: value

Returns the value of attribute name.



161
162
163
# File 'lib/interpreter/programPoints.rb', line 161

def name
  @name
end

Instance Method Details

#blueprintObject



195
196
197
# File 'lib/interpreter/programPoints.rb', line 195

def blueprint
  return self.tidy
end

#blueprint_partsObject



191
192
193
# File 'lib/interpreter/programPoints.rb', line 191

def blueprint_parts
  [self.tidy,""]
end

#go(context) ⇒ Object



168
169
170
171
172
173
174
175
176
# File 'lib/interpreter/programPoints.rb', line 168

def go(context)
  lookedUp = context.lookup(@name) if context.evaluate_references
  if lookedUp
    context.stacks[:exec].push(lookedUp)
  else
    context.stacks[:name].push(self)
    context.evaluate_references = true
  end
end

#pointsObject



178
179
180
# File 'lib/interpreter/programPoints.rb', line 178

def points
  1
end

#randomize(context) ⇒ Object



186
187
188
189
# File 'lib/interpreter/programPoints.rb', line 186

def randomize(context)
  which = context.references.sample
  @name = which
end

#tidy(level = 1) ⇒ Object



182
183
184
# File 'lib/interpreter/programPoints.rb', line 182

def tidy(level=1)
  "ref " + @name
end