class StrangerThingsDirectory::Locations

Attributes

area[RW]
description[RW]
inhabitants[RW]
name[RW]
type[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/stranger_things_directory/locations.rb, line 26
def self.all 
    @@all 
end
find(id) click to toggle source
# File lib/stranger_things_directory/locations.rb, line 30
def self.find(id)
    self.all[id-1]
end
new(name=nil, url=nil) click to toggle source
# File lib/stranger_things_directory/locations.rb, line 11
def initialize(name=nil, url=nil)
    @name = name
    @url = url
    @@all << self 
end
new_location(location) click to toggle source
# 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

Public Instance Methods

doc() click to toggle source
# File lib/stranger_things_directory/locations.rb, line 17
def doc
    @doc ||= Nokogiri::HTML(open(self.url))
end