Class: StrangerThingsDirectory::Characters
- Inherits:
-
Object
- Object
- StrangerThingsDirectory::Characters
- Defined in:
- lib/stranger_things_directory/characters.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#actor ⇒ Object
Returns the value of attribute actor.
-
#affiliation ⇒ Object
Returns the value of attribute affiliation.
-
#age ⇒ Object
Returns the value of attribute age.
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#born ⇒ Object
Returns the value of attribute born.
-
#family ⇒ Object
Returns the value of attribute family.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#name ⇒ Object
Returns the value of attribute name.
-
#occupation ⇒ Object
Returns the value of attribute occupation.
-
#residence ⇒ Object
Returns the value of attribute residence.
-
#status ⇒ Object
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(name = nil, url = nil) ⇒ Characters
constructor
A new instance of Characters.
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
#actor ⇒ Object
Returns the value of attribute actor.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def actor @actor end |
#affiliation ⇒ Object
Returns the value of attribute affiliation.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def affiliation @affiliation end |
#age ⇒ Object
Returns the value of attribute age.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def age @age end |
#aliases ⇒ Object
Returns the value of attribute aliases.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def aliases @aliases end |
#born ⇒ Object
Returns the value of attribute born.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def born @born end |
#family ⇒ Object
Returns the value of attribute family.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def family @family end |
#gender ⇒ Object
Returns the value of attribute gender.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def gender @gender end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def name @name end |
#occupation ⇒ Object
Returns the value of attribute occupation.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def occupation @occupation end |
#residence ⇒ Object
Returns the value of attribute residence.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def residence @residence end |
#status ⇒ Object
Returns the value of attribute status.
2 3 4 |
# File 'lib/stranger_things_directory/characters.rb', line 2 def status @status end |
#url ⇒ Object
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
.all ⇒ Object
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
#doc ⇒ Object
26 27 28 |
# File 'lib/stranger_things_directory/characters.rb', line 26 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |