Class: JsonMoviesParser

Inherits:
Object
  • Object
show all
Defined in:
lib/filmaffinity/json-movies-parser.rb

Instance Method Summary collapse

Instance Method Details

#to_hashes(movies) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/filmaffinity/json-movies-parser.rb', line 2

def to_hashes(movies)
  hashes = []
  movies.each do |movie|
    hash = {
      'id' => movie.id,
      'title' => movie.title
    }
    hashes << hash
  end
  hashes
end

#to_json(movies) ⇒ Object



14
15
16
17
# File 'lib/filmaffinity/json-movies-parser.rb', line 14

def to_json(movies)
  hashes = to_hashes movies
  hashes.to_json
end