Class: AllSuperheroes
- Inherits:
-
Object
- Object
- AllSuperheroes
- Defined in:
- lib/marvel_best_superheroes/allSuperheroes.rb
Constant Summary collapse
- SITE =
"https://comicvine.gamespot.com/profile/noahmaximillion/lists/top-100-marvel-superheroes/48749/"
- @@all =
array contains all superheroes information
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, url = nil) ⇒ AllSuperheroes
constructor
A new instance of AllSuperheroes.
Constructor Details
#initialize(name = nil, url = nil) ⇒ AllSuperheroes
Returns a new instance of AllSuperheroes.
14 15 16 17 18 |
# File 'lib/marvel_best_superheroes/allSuperheroes.rb', line 14 def initialize(name = nil, url = nil) @name = name @url = url @@all << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/marvel_best_superheroes/allSuperheroes.rb', line 7 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/marvel_best_superheroes/allSuperheroes.rb', line 7 def url @url end |
Class Method Details
.all ⇒ Object
29 30 31 |
# File 'lib/marvel_best_superheroes/allSuperheroes.rb', line 29 def self.all @@all end |
.create_all_superheroes ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/marvel_best_superheroes/allSuperheroes.rb', line 21 def self.create_all_superheroes Nokogiri::HTML(open(SITE)).css("ul.editorial").css("li").map do |hero| name = hero.css("h3").text url = hero.css("a").attribute("href").value self.new(name, url) end end |