Class: StrangerThingsDirectory::Locations
- Inherits:
-
Object
- Object
- StrangerThingsDirectory::Locations
- Defined in:
- lib/stranger_things_directory/locations.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#area ⇒ Object
Returns the value of attribute area.
-
#description ⇒ Object
Returns the value of attribute description.
-
#inhabitants ⇒ Object
Returns the value of attribute inhabitants.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(name = nil, url = nil) ⇒ Locations
constructor
A new instance of Locations.
Constructor Details
#initialize(name = nil, url = nil) ⇒ Locations
Returns a new instance of Locations.
11 12 13 14 15 |
# File 'lib/stranger_things_directory/locations.rb', line 11 def initialize(name=nil, url=nil) @name = name @url = url @@all << self end |
Instance Attribute Details
#area ⇒ Object
Returns the value of attribute area.
2 3 4 |
# File 'lib/stranger_things_directory/locations.rb', line 2 def area @area end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/stranger_things_directory/locations.rb', line 2 def description @description end |
#inhabitants ⇒ Object
Returns the value of attribute inhabitants.
2 3 4 |
# File 'lib/stranger_things_directory/locations.rb', line 2 def inhabitants @inhabitants end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/stranger_things_directory/locations.rb', line 2 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/stranger_things_directory/locations.rb', line 2 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/stranger_things_directory/locations.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
26 27 28 |
# File 'lib/stranger_things_directory/locations.rb', line 26 def self.all @@all end |
.find(id) ⇒ Object
30 31 32 |
# File 'lib/stranger_things_directory/locations.rb', line 30 def self.find(id) self.all[id-1] end |
.new_location(location) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/stranger_things_directory/locations.rb', line 5 def self.new_location(location) self.new( location.css("a figure figcaption.category-page__trending-page-title").text, "https://strangerthings.fandom.com#{location.css("a").attribute("href").text}" ) end |
Instance Method Details
#doc ⇒ Object
17 18 19 |
# File 'lib/stranger_things_directory/locations.rb', line 17 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |