Class: Kinopoisk::Person
- Inherits:
-
Object
- Object
- Kinopoisk::Person
- Defined in:
- lib/kinopoisk/person.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns a string containing name in russian.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#best_movies ⇒ Object
Returns an array of strings containing best movie titles.
-
#birthdate ⇒ Object
Returns a birthdate date object.
-
#birthplace ⇒ Object
Returns a string containing birthplace.
-
#career ⇒ Object
Returns an array of strings containing career professions.
-
#first_movie ⇒ Object
Returns a string containing year of first movie.
-
#genres ⇒ Object
Returns an array of strings containing genres.
-
#height ⇒ Object
Returns a string containing height.
-
#initialize(id, name = nil) ⇒ Person
constructor
New instance can be initialized with id(string or integer) and an optional name to make it easier to differentiate Kinopoisk::Person instances.
-
#last_movie ⇒ Object
Returns a string containing year of last movie.
-
#name_en ⇒ Object
Returns a string containing name in english.
-
#partner ⇒ Object
Returns a string containing partner’s name.
-
#poster ⇒ Object
Returns a url to a poster.
-
#total_movies ⇒ Object
Returns an integer total movie count.
Constructor Details
#initialize(id, name = nil) ⇒ Person
13 14 15 16 17 |
# File 'lib/kinopoisk/person.rb', line 13 def initialize(id, name=nil) @id = id @url = "https://www.kinopoisk.ru/name/#{id}/" @name = name end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/kinopoisk/person.rb', line 4 def id @id end |
#name ⇒ Object
Returns a string containing name in russian
25 26 27 |
# File 'lib/kinopoisk/person.rb', line 25 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/kinopoisk/person.rb', line 4 def url @url end |
Instance Method Details
#best_movies ⇒ Object
Returns an array of strings containing best movie titles
65 66 67 |
# File 'lib/kinopoisk/person.rb', line 65 def best_movies doc.search('#BestFilmList a').map(&:text) end |
#birthdate ⇒ Object
Returns a birthdate date object
40 41 42 |
# File 'lib/kinopoisk/person.rb', line 40 def birthdate Date.strptime doc.search("td.birth").first.attr 'birthdate' end |
#birthplace ⇒ Object
Returns a string containing birthplace
45 46 47 |
# File 'lib/kinopoisk/person.rb', line 45 def birthplace search_by_text('место рождения').split(', ').first end |
#career ⇒ Object
Returns an array of strings containing career professions
55 56 57 |
# File 'lib/kinopoisk/person.rb', line 55 def career search_by_text('карьера').split(', ') end |
#first_movie ⇒ Object
Returns a string containing year of first movie
70 71 72 |
# File 'lib/kinopoisk/person.rb', line 70 def first_movie doc.search("a[title='Первый фильм']").text end |
#genres ⇒ Object
Returns an array of strings containing genres
50 51 52 |
# File 'lib/kinopoisk/person.rb', line 50 def genres search_by_text('жанры').split(', ') end |
#height ⇒ Object
Returns a string containing height
80 81 82 |
# File 'lib/kinopoisk/person.rb', line 80 def height search_by_text 'рост' end |
#last_movie ⇒ Object
Returns a string containing year of last movie
75 76 77 |
# File 'lib/kinopoisk/person.rb', line 75 def last_movie doc.search("a[title='Последний фильм']").text end |
#name_en ⇒ Object
Returns a string containing name in english
30 31 32 |
# File 'lib/kinopoisk/person.rb', line 30 def name_en doc.search("#headerPeople span[itemprop='alternativeHeadline']").text.strip end |
#partner ⇒ Object
Returns a string containing partner’s name
35 36 37 |
# File 'lib/kinopoisk/person.rb', line 35 def partner doc.search("//td[@class='type'][contains(text(),'супруг')]/following-sibling::*").text end |
#poster ⇒ Object
Returns a url to a poster
20 21 22 |
# File 'lib/kinopoisk/person.rb', line 20 def poster doc.search(".film-img-box img").first.attr 'src' end |
#total_movies ⇒ Object
Returns an integer total movie count
60 61 62 |
# File 'lib/kinopoisk/person.rb', line 60 def total_movies search_by_text('всего фильмов').to_i end |