Class: Film
- Inherits:
-
Object
- Object
- Film
- Includes:
- Comparable
- Defined in:
- lib/DreamTeam/Films/parsing_films.rb
Instance Attribute Summary collapse
-
#crew ⇒ Object
readonly
Returns the value of attribute crew.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#imDbRating ⇒ Object
readonly
Returns the value of attribute imDbRating.
-
#imDbRatingCount ⇒ Object
readonly
Returns the value of attribute imDbRatingCount.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#title_full ⇒ Object
readonly
Returns the value of attribute title_full.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #<=>(an_other) ⇒ Object
- #help(arr, i) ⇒ Object
-
#initialize(arr_film) ⇒ Film
constructor
конструктор класса.
Constructor Details
#initialize(arr_film) ⇒ Film
конструктор класса. из строки вытаскивает функцией help нужные данные для полей
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 10 def initialize (arr_film) arr = arr_film.to_s.gsub('{', '').gsub('}', '').gsub('",', '"^^^').split('^^^') @id = help(arr, 0) @rank = help(arr, 1).to_i @title = help(arr, 2) @title_full = help(arr, 3) @year = help(arr, 4).to_i @image = help(arr, 5) @crew = help(arr, 6) @imDbRating = help(arr, 7).to_f @imDbRatingCount = help(arr, 8).to_i end |
Instance Attribute Details
#crew ⇒ Object (readonly)
Returns the value of attribute crew.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def crew @crew end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def id @id end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def image @image end |
#imDbRating ⇒ Object (readonly)
Returns the value of attribute imDbRating.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def imDbRating @imDbRating end |
#imDbRatingCount ⇒ Object (readonly)
Returns the value of attribute imDbRatingCount.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def imDbRatingCount @imDbRatingCount end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def rank @rank end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def title @title end |
#title_full ⇒ Object (readonly)
Returns the value of attribute title_full.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def title_full @title_full end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
7 8 9 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7 def year @year end |
Instance Method Details
#<=>(an_other) ⇒ Object
23 24 25 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 23 def <=>(an_other) an_other.year <=> self.year end |
#help(arr, i) ⇒ Object
27 28 29 |
# File 'lib/DreamTeam/Films/parsing_films.rb', line 27 def help(arr, i) return arr[i][arr[i].index(':"') + 2, arr[i].length - arr[i].index(':"') - 3] end |