Class: IndoorJungle::Plant

Inherits:
Object
  • Object
show all
Defined in:
lib/indoor_jungle/plant.rb

Constant Summary collapse

@@all =
[]
@@plants =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

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

#plantObject

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_urlObject

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_rangeObject

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

#sunlightObject

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

#temperatureObject

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

#waterObject

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

.allObject



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