Class: DustinAndersonCLIApp::Movie

Inherits:
Object
  • Object
show all
Defined in:
lib/dustin_anderson_cli_app.rb

Constant Summary collapse

OPTIONS =
"Here are your options for lists: \n" "To see the top 10 enter: 'top 10'\n" "To see the top 25 enter: 'top 25'\n" "To see the top 50 enter: 'top 50'\n" "To see the full list enter: 'list'\n" "To see a random movie summary from the list enter 'random'\n" "To leave the program enter 'exit'\n\n"
@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rank = nil, title = nil, rating = nil, reviews = nil, summary = nil, parental = nil, genre = nil, theatre_date = nil, studio = nil) ⇒ Movie

Returns a new instance of Movie.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dustin_anderson_cli_app.rb', line 9

def initialize(rank = nil, title = nil, rating = nil, reviews = nil, summary = nil, parental = nil, genre = nil, theatre_date = nil, studio = nil)
  @rank = rank
  @title = title
  @rating = rating
  @reviews = reviews
  @summary = summary
  @parental = parental
  @genre = genre
  @theatre_date = theatre_date
  @studio = studio
  @@all << self
end

Instance Attribute Details

#genreObject

Returns the value of attribute genre.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def genre
  @genre
end

#movie_scraperObject

Returns the value of attribute movie_scraper.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def movie_scraper
  @movie_scraper
end

#parentalObject

Returns the value of attribute parental.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def parental
  @parental
end

#rankObject

Returns the value of attribute rank.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def rank
  @rank
end

#ratingObject

Returns the value of attribute rating.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def rating
  @rating
end

#reviewsObject

Returns the value of attribute reviews.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def reviews
  @reviews
end

#studioObject

Returns the value of attribute studio.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def studio
  @studio
end

#summaryObject

Returns the value of attribute summary.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def summary
  @summary
end

#theatre_dateObject

Returns the value of attribute theatre_date.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def theatre_date
  @theatre_date
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/dustin_anderson_cli_app.rb', line 5

def title
  @title
end

Class Method Details

.allObject



22
23
24
# File 'lib/dustin_anderson_cli_app.rb', line 22

def self.all
  @@all
end

.list_allObject



44
45
46
47
48
# File 'lib/dustin_anderson_cli_app.rb', line 44

def self.list_all
  DustinAndersonCLIApp::Movie.all[0..99].each do |film|
    puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
  end
end

.movie_summaryObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/dustin_anderson_cli_app.rb', line 50

def self.movie_summary
  another_summary = ""
  while another_summary != 'options'
    if another_summary == 'exit'
      break
    end
    puts "Please enter the rank of the move you would like the summary of: "
    summary_input = gets.strip!
    if summary_input == 'exit'
      break
    end
    if summary_input.to_i >= 1 && summary_input.to_i <= 100
      self.all.each do |film|
        if film.rank == summary_input
          puts "#{film.title}:"
          puts film.summary
          puts "\nIf you would like a few more details about the movie enter 'more'.If you want another movie summary enter 'yes' or press the enter key. Else type 'options' for list of options."
          another_summary = gets.downcase.strip!
          if another_summary == 'more'
            puts "#{film.title}: "
            puts " Parental Rating: #{film.parental}\n Film Genre: #{film.genre}\n In Theatres: #{film.theatre_date}\n Studio: #{film.studio}\n"
            puts "\nIf you want another movie summary enter 'yes' or press the enter key. Else type 'options' for list of options."
            another_summary = gets.downcase.strip!
          elsif another_summary == 'options' || another_summary == ""
            break
          end
        end
      end
    end
  end
  puts "\n#{OPTIONS}"
end

.random_movie_summaryObject



83
84
85
86
87
# File 'lib/dustin_anderson_cli_app.rb', line 83

def self.random_movie_summary
  random_movie_summary = self.all.sample
  puts "#{random_movie_summary.title} #{random_movie_summary.rank}: "
  puts "#{random_movie_summary.summary}\n"
end

.top_fiftyObject



38
39
40
41
42
# File 'lib/dustin_anderson_cli_app.rb', line 38

def self.top_fifty
  DustinAndersonCLIApp::Movie.all[0..49].each do |film|
    puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
  end
end

.top_tenObject



26
27
28
29
30
# File 'lib/dustin_anderson_cli_app.rb', line 26

def self.top_ten
  DustinAndersonCLIApp::Movie.all[0..9].each do |film|
    puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
  end
end

.top_twentyfiveObject



32
33
34
35
36
# File 'lib/dustin_anderson_cli_app.rb', line 32

def self.top_twentyfive
  DustinAndersonCLIApp::Movie.all[0..24].each do |film|
    puts "#{film.rank}. #{film.title} #{film.rating} #{film.reviews}"
  end
end