Class: Nudge::InstructionPoint
Defined Under Namespace
Classes: InstructionNotFoundError
Instance Attribute Summary collapse
Instance Method Summary
collapse
#each
Constructor Details
Returns a new instance of InstructionPoint.
206
207
208
|
# File 'lib/interpreter/programPoints.rb', line 206
def initialize(name)
@name = name
end
|
Instance Attribute Details
#effects ⇒ Object
Returns the value of attribute effects.
205
206
207
|
# File 'lib/interpreter/programPoints.rb', line 205
def effects
@effects
end
|
#name ⇒ Object
Returns the value of attribute name.
205
206
207
|
# File 'lib/interpreter/programPoints.rb', line 205
def name
@name
end
|
#requirements ⇒ Object
Returns the value of attribute requirements.
205
206
207
|
# File 'lib/interpreter/programPoints.rb', line 205
def requirements
@requirements
end
|
Instance Method Details
#blueprint ⇒ Object
248
249
250
|
# File 'lib/interpreter/programPoints.rb', line 248
def blueprint
return self.tidy
end
|
#blueprint_parts ⇒ Object
244
245
246
|
# File 'lib/interpreter/programPoints.rb', line 244
def blueprint_parts
[self.tidy,""]
end
|
#classLookup ⇒ Object
214
215
216
217
218
|
# File 'lib/interpreter/programPoints.rb', line 214
def classLookup
self.className.constantize
rescue NameError
raise InstructionNotFoundError, "#{self.className} is not an active instruction in this context"
end
|
#className ⇒ Object
210
211
212
|
# File 'lib/interpreter/programPoints.rb', line 210
def className
"#{@name.camelize}Instruction"
end
|
#go(context) ⇒ Object
231
232
233
234
235
236
237
|
# File 'lib/interpreter/programPoints.rb', line 231
def go(context)
className = self.classLookup
context.instructions_library[className].go
rescue InstructionNotFoundError => exc
msg = ValuePoint.new("error", exc.message)
context.stacks[:error].push msg
end
|
#points ⇒ Object
224
225
226
|
# File 'lib/interpreter/programPoints.rb', line 224
def points
1
end
|
#randomize(context) ⇒ Object
239
240
241
242
|
# File 'lib/interpreter/programPoints.rb', line 239
def randomize(context)
instructionName = context.instructions.sample.to_s
@name = instructionName.slice(0..-12).underscore
end
|
#tidy(level = 1) ⇒ Object
220
221
222
|
# File 'lib/interpreter/programPoints.rb', line 220
def tidy(level=1)
"do " + @name
end
|