class Superheroes
Attributes
aliases[RW]
biography[RW]
birthday[RW]
charactertype[RW]
gender[RW]
name[RW]
powers[RW]
realname[RW]
supername[RW]
Public Class Methods
all()
click to toggle source
# File lib/marvel_best_superheroes/superhero.rb, line 47 def self.all @@all end
get_superhero_infos(site)
click to toggle source
# File lib/marvel_best_superheroes/superhero.rb, line 29 def self.get_superhero_infos(site) Superheroes.reset doc = Nokogiri::HTML(open(site)).css("table.table tbody") name = Nokogiri::HTML(open(site)).css("h1").text.strip biography = Nokogiri::HTML(open(site)).css("h3.display-view").text supername = doc.css("div[data-field='realName']").text.strip.split(/\n/).first aliases = doc.css("div[data-field='aliases']").text.strip.split("\r\n").map{|i| "\n #{i}"}.join realname = doc.css("div[data-field='realName']").text.strip.split(/\n/).last.strip gender = doc.css("div[data-field='gender']").text.strip charactertype = doc.css("div[data-field='origin']").text.strip birthday = doc.css("div[data-field='birthday']").text.strip powers = doc.css("div[data-field='powers']").text self.new(name, biography, supername, realname, aliases, gender, charactertype, birthday, powers) end
new(name = nil, biography = nil, supername = nil, realname = nil, aliases = nil, gender = nil, charactertype = nil, birthday = nil, powers = nil)
click to toggle source
# File lib/marvel_best_superheroes/superhero.rb, line 12 def initialize(name = nil, biography = nil, supername = nil, realname = nil, aliases = nil, gender = nil, charactertype = nil, birthday = nil, powers = nil) @name = name @biography = biography @supername = supername @realname = realname @aliases = aliases @gender = gender @charactertype = charactertype @birthday = birthday @powers = powers @@all << self end
reset()
click to toggle source
# File lib/marvel_best_superheroes/superhero.rb, line 51 def self.reset @@all = [] end
Public Instance Methods
allsites()
click to toggle source
# File lib/marvel_best_superheroes/superhero.rb, line 25 def allsites AllSuperheroes.all.map { |e| "#{BASEPATH}#{e.url}"} end