T
Thufir
The following runs, which is good. But, I get these "nil" outputs for
each object, rather than even the ?hash code? or ?object id? for each
object.
I get an error if I try to: save.creature from within the loop. I'm
trying to use the module:
thufir@arrakis ~/Desktop/dwemthys $
thufir@arrakis ~/Desktop/dwemthys $ ruby db_crud_create.rb
-- create_table
creatures)
SQL (0.011644) CREATE TABLE creatures ("id" INTEGER PRIMARY KEY NOT
NULL, "type" varchar(255) DEFAULT NULL, "life" integer DEFAULT NULL,
"strength" integer DEFAULT NULL, "charisma" integer DEFAULT NULL,
"weapon" integer DEFAULT NULL)
-> 0.1323s
nil
nil
nil
nil
nil
thufir@arrakis ~/Desktop/dwemthys $
thufir@arrakis ~/Desktop/dwemthys $ tail db_crud_create.rb -n 5
5.times do |index|
creature = Instantiate.randomCreature
puts creature.inspect
end
thufir@arrakis ~/Desktop/dwemthys $
thufir@arrakis ~/Desktop/dwemthys $ cat instantiate.rb
require 'dragon'
module Instantiate
def Instantiate.randomCreature()
creatureType=Kernel.rand(0)
case creatureType
when 0
Dragon.new
when 1
Dragon.new
end #case
end #makeCreature
end # Instantiate
thufir@arrakis ~/Desktop/dwemthys $
thanks,
Thufir
each object, rather than even the ?hash code? or ?object id? for each
object.
I get an error if I try to: save.creature from within the loop. I'm
trying to use the module:
thufir@arrakis ~/Desktop/dwemthys $
thufir@arrakis ~/Desktop/dwemthys $ ruby db_crud_create.rb
-- create_table
SQL (0.011644) CREATE TABLE creatures ("id" INTEGER PRIMARY KEY NOT
NULL, "type" varchar(255) DEFAULT NULL, "life" integer DEFAULT NULL,
"strength" integer DEFAULT NULL, "charisma" integer DEFAULT NULL,
"weapon" integer DEFAULT NULL)
-> 0.1323s
nil
nil
nil
nil
nil
thufir@arrakis ~/Desktop/dwemthys $
thufir@arrakis ~/Desktop/dwemthys $ tail db_crud_create.rb -n 5
5.times do |index|
creature = Instantiate.randomCreature
puts creature.inspect
end
thufir@arrakis ~/Desktop/dwemthys $
thufir@arrakis ~/Desktop/dwemthys $ cat instantiate.rb
require 'dragon'
module Instantiate
def Instantiate.randomCreature()
creatureType=Kernel.rand(0)
case creatureType
when 0
Dragon.new
when 1
Dragon.new
end #case
end #makeCreature
end # Instantiate
thufir@arrakis ~/Desktop/dwemthys $
thanks,
Thufir