Class: BadFruit::Movie

Inherits:
Object
  • Object
show all
Defined in:
lib/badfruit/Movies/movie.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(movieHash, badfruit) ⇒ Movie

Returns a new instance of Movie.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/badfruit/Movies/movie.rb', line 6

def initialize(movieHash, badfruit)
  @id = movieHash["id"]
  @name = movieHash["title"]
  @year = movieHash["year"]
  @genres = movieHash["genres"]
  @mpaa_rating = movieHash["mpaa_rating"]
  @runtime = movieHash["runtime"]
  @release_dates = movieHash["release_dates"]
  @synopsis = movieHash["synopsis"]
  @cast = movieHash["abridged_cast"]
  @directors = movieHash["abridged_directors"]
  @links = movieHash["links"]
  @scores = Scores.new(movieHash["ratings"]) #single score object containing two scores
  @posters = Posters.new(movieHash["posters"]) #single posters object containing four poster urls
  @badfruit = badfruit
  @moviehash = movieHash
end

Instance Attribute Details

#castObject

Returns the value of attribute cast.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def cast
  @cast
end

#directorsObject

Returns the value of attribute directors.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def directors
  @directors
end

#genresObject

Returns the value of attribute genres.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def genres
  @genres
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def id
  @id
end

Returns the value of attribute links.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def links
  @links
end

#mpaa_ratingObject

Returns the value of attribute mpaa_rating.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def mpaa_rating
  @mpaa_rating
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def name
  @name
end

#postersObject

Returns the value of attribute posters.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def posters
  @posters
end

#release_datesObject

Returns the value of attribute release_dates.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def release_dates
  @release_dates
end

#runtimeObject

Returns the value of attribute runtime.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def runtime
  @runtime
end

#scoresObject

Returns the value of attribute scores.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def scores
  @scores
end

#synopsisObject

Returns the value of attribute synopsis.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def synopsis
  @synopsis
end

#yearObject

Returns the value of attribute year.



3
4
5
# File 'lib/badfruit/Movies/movie.rb', line 3

def year
  @year
end

Instance Method Details

#full_castObject

returns an array of Actor objects



25
26
27
# File 'lib/badfruit/Movies/movie.rb', line 25

def full_cast
  return @badfruit.parse_actors_array(JSON.parse(@badfruit.get_movie_info(@id, "cast")))
end

#infoObject



39
40
41
# File 'lib/badfruit/Movies/movie.rb', line 39

def info
  @moviehash
end

#reviewsObject

returns an array of Review objects



30
31
32
33
34
35
36
37
# File 'lib/badfruit/Movies/movie.rb', line 30

def reviews
  data = JSON.parse(@badfruit.get_movie_info(@id, "reviews"))
  reviews = Array.new
  data["reviews"].each do |review|
    reviews.push(Review.new(review))
  end
   return reviews 
end