Class: PlantToxicity::List

Inherits:
Object
  • Object
show all
Defined in:
lib/plant_toxicity/list.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(letter) ⇒ List

Returns a new instance of List.



8
9
10
11
12
# File 'lib/plant_toxicity/list.rb', line 8

def initialize(letter)
  @letter = letter.upcase
  @plants = PlantToxicity::Scraper.get_list(@letter)
  @@all << self
end

Instance Attribute Details

#letterObject

Returns the value of attribute letter.



3
4
5
# File 'lib/plant_toxicity/list.rb', line 3

def letter
  @letter
end

#plantsObject

Returns the value of attribute plants.



3
4
5
# File 'lib/plant_toxicity/list.rb', line 3

def plants
  @plants
end

#scraperObject (readonly)

Returns the value of attribute scraper.



4
5
6
# File 'lib/plant_toxicity/list.rb', line 4

def scraper
  @scraper
end

Class Method Details

.allObject



14
15
16
# File 'lib/plant_toxicity/list.rb', line 14

def self.all
  @@all
end

Instance Method Details

#select_plant(input) ⇒ Object



18
19
20
21
22
# File 'lib/plant_toxicity/list.rb', line 18

def select_plant(input)
  plant = self.plants[input]
  PlantToxicity::Scraper.get_plant_details(plant)
  plant
end