Class: StrangerThingsDirectory::Characters

Inherits:
Object
  • Object
show all
Defined in:
lib/stranger_things_directory/characters.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, url = nil) ⇒ Characters

Returns a new instance of Characters.



12
13
14
15
16
# File 'lib/stranger_things_directory/characters.rb', line 12

def initialize(name=nil, url=nil)
@name = name
@url = url
@@all << self
end

Instance Attribute Details

#actorObject

Returns the value of attribute actor.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def actor
  @actor
end

#affiliationObject

Returns the value of attribute affiliation.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def affiliation
  @affiliation
end

#ageObject

Returns the value of attribute age.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def age
  @age
end

#aliasesObject

Returns the value of attribute aliases.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def aliases
  @aliases
end

#bornObject

Returns the value of attribute born.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def born
  @born
end

#familyObject

Returns the value of attribute family.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def family
  @family
end

#genderObject

Returns the value of attribute gender.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def gender
  @gender
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def name
  @name
end

#occupationObject

Returns the value of attribute occupation.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def occupation
  @occupation
end

#residenceObject

Returns the value of attribute residence.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def residence
  @residence
end

#statusObject

Returns the value of attribute status.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def status
  @status
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/stranger_things_directory/characters.rb', line 2

def url
  @url
end

Class Method Details

.allObject



18
19
20
# File 'lib/stranger_things_directory/characters.rb', line 18

def self.all
@@all
end

.find(index) ⇒ Object



22
23
24
# File 'lib/stranger_things_directory/characters.rb', line 22

def self.find(index)
@@all[index -1]
end

.new_character(char) ⇒ Object



6
7
8
9
10
11
# File 'lib/stranger_things_directory/characters.rb', line 6

def self.new_character(char)
self.new(
    char.css("a figure figcaption.category-page__trending-page-title").text, 
    "https://strangerthings.fandom.com#{char.css("a").attribute("href").text}"
)
end

Instance Method Details

#docObject



26
27
28
# File 'lib/stranger_things_directory/characters.rb', line 26

def doc 
@doc ||= Nokogiri::HTML(open(self.url)) 
end