Class: IndoorJungle::Plant
- Inherits:
-
Object
- Object
- IndoorJungle::Plant
- Defined in:
- lib/indoor_jungle/plant.rb
Constant Summary collapse
- @@all =
[]
- @@plants =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
-
#plant ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
-
#plant_url ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
-
#price_range ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
-
#sunlight ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
-
#temperature ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
-
#water ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #add_plant_attributes(attributes_hash) ⇒ Object
-
#initialize(plant_hash) ⇒ Plant
constructor
A new instance of Plant.
Constructor Details
#initialize(plant_hash) ⇒ Plant
Returns a new instance of Plant.
10 11 12 13 |
# File 'lib/indoor_jungle/plant.rb', line 10 def initialize(plant_hash) plant_hash.each {|key, value| self.send(("#{key}="), value)} @@all << self end |
Instance Attribute Details
#name ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def name @name end |
#plant ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def plant @plant end |
#plant_url ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def plant_url @plant_url end |
#price_range ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def price_range @price_range end |
#sunlight ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def sunlight @sunlight end |
#temperature ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def temperature @temperature end |
#water ⇒ Object
modeling after the student creator, I will need a place to store all the plants and then each plant’s attributes
5 6 7 |
# File 'lib/indoor_jungle/plant.rb', line 5 def water @water end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/indoor_jungle/plant.rb', line 15 def self.all @@all end |
.create_from_collection(plants_array) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/indoor_jungle/plant.rb', line 19 def self.create_from_collection(plants_array) plants_array.each do |plant| plant = self.new(plant) @@plants << plant end end |
Instance Method Details
#add_plant_attributes(attributes_hash) ⇒ Object
26 27 28 |
# File 'lib/indoor_jungle/plant.rb', line 26 def add_plant_attributes(attributes_hash) attributes_hash.each {|key, value| self.send(("#{key}="), value)} end |