Class: GoShawty::CelebrityMaker
- Inherits:
-
Object
- Object
- GoShawty::CelebrityMaker
- Defined in:
- lib/go_shawty/celebrity_maker.rb
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#bio ⇒ Object
Returns the value of attribute bio.
-
#birthplace ⇒ Object
Returns the value of attribute birthplace.
-
#born ⇒ Object
Returns the value of attribute born.
-
#died ⇒ Object
Returns the value of attribute died.
-
#known ⇒ Object
Returns the value of attribute known.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(age = nil, born = nil, died = "Died: N/A", birthplace = nil, known = nil, bio = nil) ⇒ CelebrityMaker
constructor
A new instance of CelebrityMaker.
Constructor Details
#initialize(age = nil, born = nil, died = "Died: N/A", birthplace = nil, known = nil, bio = nil) ⇒ CelebrityMaker
Returns a new instance of CelebrityMaker.
4 5 6 7 8 9 10 11 |
# File 'lib/go_shawty/celebrity_maker.rb', line 4 def initialize(age = nil, born = nil, died = "Died: N/A", birthplace = nil, known = nil, bio = nil) @age = age @born = born @died = died @birthplace = birthplace @known = known @bio = bio end |
Instance Attribute Details
#age ⇒ Object
Returns the value of attribute age.
2 3 4 |
# File 'lib/go_shawty/celebrity_maker.rb', line 2 def age @age end |
#bio ⇒ Object
Returns the value of attribute bio.
2 3 4 |
# File 'lib/go_shawty/celebrity_maker.rb', line 2 def bio @bio end |
#birthplace ⇒ Object
Returns the value of attribute birthplace.
2 3 4 |
# File 'lib/go_shawty/celebrity_maker.rb', line 2 def birthplace @birthplace end |
#born ⇒ Object
Returns the value of attribute born.
2 3 4 |
# File 'lib/go_shawty/celebrity_maker.rb', line 2 def born @born end |
#died ⇒ Object
Returns the value of attribute died.
2 3 4 |
# File 'lib/go_shawty/celebrity_maker.rb', line 2 def died @died end |
#known ⇒ Object
Returns the value of attribute known.
2 3 4 |
# File 'lib/go_shawty/celebrity_maker.rb', line 2 def known @known end |
Class Method Details
.scrape_celeb_page(url) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/go_shawty/celebrity_maker.rb', line 13 def self.scrape_celeb_page(url) new_page = self.new celeb_doc = Nokogiri::HTML(open(url)) celeb_doc.css("div.bio-info-div").each do |fact| if fact.text.include? "years" new_page.age = fact.text elsif fact.text.include? "Born" new_page.born = fact.text elsif fact.text.include? "Died" new_page.died = fact.text elsif fact.text.include? "Birthplace" new_page.birthplace = fact.text elsif fact.text.include? "known" new_page.known = fact.text end end new_page.bio = celeb_doc.css("div.bio-body p").text new_page end |