You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
420 B
16 lines
420 B
class Fruit
|
|
DB = PG.connect(host: "localhost", port: 5432, dbname: 'simplerails')
|
|
|
|
def initialize(opts = {})
|
|
@id = opts["id"].to_i
|
|
@name = opts["name"]
|
|
@color = opts["color"]
|
|
@readyToEat = (opts["readytoeat"]=='t')?true:false
|
|
end
|
|
|
|
def self.all
|
|
results = DB.exec("SELECT * FROM fruits;")
|
|
return results.map { |fruit_opts| Fruit.new(fruit_opts)}
|
|
end
|
|
end
|