Class: ImdbCelebrity::Celebrity
- Inherits:
-
Object
- Object
- ImdbCelebrity::Celebrity
- Defined in:
- lib/imdb_celebrity/celebrity.rb
Overview
Represents a celebrity on IMDB.com
Instance Attribute Summary collapse
-
#biography ⇒ Object
Returns the value of attribute biography.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name(flag = false) ⇒ Object
Returns the value of attribute name.
-
#nationality ⇒ Object
Returns the value of attribute nationality.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#real_name ⇒ Object
Returns the value of attribute real_name.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #celebrity_data ⇒ Object
-
#initialize(imdb_id, title = nil, parser = "HpricotParser") ⇒ Celebrity
constructor
Initialize a new IMDB celebrity object with it’s IMDB id (as a String).
- #to_s ⇒ Object
Constructor Details
#initialize(imdb_id, title = nil, parser = "HpricotParser") ⇒ Celebrity
Initialize a new IMDB celebrity object with it’s IMDB id (as a String)
celebrity = Imdb::Celebrity.new("0095016", "celeb name", "Parsing Class")
Imdb::Celebrity objects are lazy loading, meaning that no HTTP request will be performed when a new object is created. Only when you use an accessor that needs the remote data, a HTTP request is made (once).
17 18 19 20 21 22 |
# File 'lib/imdb_celebrity/celebrity.rb', line 17 def initialize imdb_id, title = nil, parser = "HpricotParser" @id = imdb_id @url = "http://www.imdb.com/name/nm#{imdb_id}/bio" @name = title.gsub(/"/, "") if title @parser = initialize_parser parser end |
Instance Attribute Details
#biography ⇒ Object
Returns the value of attribute biography.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def biography @biography end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def id @id end |
#name(flag = false) ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def name @name end |
#nationality ⇒ Object
Returns the value of attribute nationality.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def nationality @nationality end |
#parser ⇒ Object
Returns the value of attribute parser.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def parser @parser end |
#real_name ⇒ Object
Returns the value of attribute real_name.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def real_name @real_name end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/imdb_celebrity/celebrity.rb', line 6 def url @url end |
Instance Method Details
#celebrity_data ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/imdb_celebrity/celebrity.rb', line 52 def celebrity_data @real_name ||=@parser.real_name @biography ||= @parser.biography @height ||= @parser.height @nationality ||= @parser.nationality return true end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/imdb_celebrity/celebrity.rb', line 24 def to_s [@id, @url, @name, @real_name, @biography, @height, @nationality] end |