Last active
August 4, 2017 07:29
-
-
Save Sihui/8408471ca04a66435d8fa9d3861f2239 to your computer and use it in GitHub Desktop.
Design Pattern: Iterator and Movie Collections
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_all_movies | |
| movies = [] | |
| while netflix_movie_iterator.has_next? | |
| movies << netflix_movie_iterator.next | |
| end | |
| while amazon_movie_iterator.has_next? | |
| movies << amazon_movie_iterator.next | |
| end | |
| while hulu_movie_iterator.has_next? | |
| movies << hulu_movie_iterator.next | |
| end | |
| while youtube_movie_iterator.has_next? | |
| movies << youtube_movie_iterator.next | |
| end | |
| while hbo_movie_iterator.has_next? | |
| movies << hbo_movie_iterator.next | |
| end | |
| movies | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment