File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed
Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -5,23 +5,20 @@ class << self
55 # film["name"], film["rating_kinopoisk"], film["rating_imdb"],
66 # film["genres"], film["year"], film["access_level"], film["country"]
77 def rating ( _array )
8- array = CSV . readlines ( './test/fixtures/films.csv' , headers : true ) . to_a
9- rating_kinopoisk = [ ]
10- array . map do |row |
11- rating_kinopoisk . push row [ 1 ] . to_f if row [ 6 ] . to_s . split ( ',' ) . count > 1 && row [ 1 ] . to_i . positive?
12- end
8+ array = CSV . readlines ( './test/fixtures/films.csv' , headers : true )
9+
10+ rating_kinopoisk = ( array . map do |film |
11+ film [ 'rating_kinopoisk' ] . to_f if film [ 'country' ] . to_s . split ( ',' ) . count > 1 && film [ 'rating_kinopoisk' ] . to_i . positive?
12+ end ) . compact
1313 rating_kinopoisk . reduce ( :+ ) / rating_kinopoisk . size
1414 end
1515
1616 def chars_count ( _films , threshold )
17- films = CSV . readlines ( './test/fixtures/films.csv' , headers : true ) . to_a
18- name = [ ]
19- films . map do |row |
20- name . push row [ 0 ] if row [ 1 ] . to_f >= threshold && row [ 0 ] . count ( 'и' ) . positive?
21- end
22-
23- sum = name . map { |film | film . count ( 'и' ) }
24- sum . reduce ( :+ )
17+ films = CSV . readlines ( './test/fixtures/films.csv' , headers : true )
18+ search_letters = films . map do |film |
19+ film [ 'name' ] if film [ 'name' ] . count ( 'и' ) . positive? && film [ 'rating_kinopoisk' ] . to_f >= threshold
20+ end . compact
21+ search_letters . map { |film | film . count ( 'и' ) } . reduce ( :+ )
2522 end
2623 end
2724 end
You can’t perform that action at this time.
0 commit comments