Sha256: c7992ddb76449555549d612042799c20adfe5170387fc32ed0b8b877b2637b7a
Contents?: true
Size: 704 Bytes
Versions: 1
Compression:
Stored size: 704 Bytes
Contents
require 'pry' require "nokogiri" require 'open-uri' class AllSuperheroes attr_accessor :name, :url SITE = "https://comicvine.gamespot.com/profile/noahmaximillion/lists/top-100-marvel-superheroes/48749/" #array contains all superheroes information @@all = [] def initialize(name = nil, url = nil) @name = name @url = url @@all << self end 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 def self.all @@all end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
marvel_best_superheroes-0.1.0 | lib/marvel_best_superheroes/allSuperheroes.rb |