Class: Film

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/DreamTeam/Films/parsing_films.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#crewObject (readonly)

Returns the value of attribute crew.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def crew
  @crew
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def image
  @image
end

#imDbRatingObject (readonly)

Returns the value of attribute imDbRating.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def imDbRating
  @imDbRating
end

#imDbRatingCountObject (readonly)

Returns the value of attribute imDbRatingCount.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def imDbRatingCount
  @imDbRatingCount
end

#rankObject (readonly)

Returns the value of attribute rank.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def rank
  @rank
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/DreamTeam/Films/parsing_films.rb', line 7

def title
  @title
end

#title_fullObject (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

#yearObject (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