Class: Hogwarts::Atlas
- Inherits:
-
Object
- Object
- Hogwarts::Atlas
- Defined in:
- lib/atlas.rb
Constant Summary collapse
- @@all =
[]
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, url) ⇒ Atlas
constructor
A new instance of Atlas.
Constructor Details
#initialize(name, url) ⇒ Atlas
Returns a new instance of Atlas.
10 11 12 13 14 |
# File 'lib/atlas.rb', line 10 def initialize(name, url) @name = name @url = url @@all << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/atlas.rb', line 5 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/atlas.rb', line 5 def url @url end |
Class Method Details
.all ⇒ Object
30 31 32 |
# File 'lib/atlas.rb', line 30 def self.all @@all end |
.scrape_atlas ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/atlas.rb', line 16 def self.scrape_atlas maps = [] doc = Nokogiri::HTML(open("https://www.hp-lexicon.org/list/wizarding-atlas/atlas-of-hogwarts/")) info = doc.css(".col-md-12 ul li a") info.each do |n| atlas = {} atlas[:name] = n.text atlas[:url] = n.attr("href") maps << atlas end maps end |