Class: Movlog::Movie

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

Overview

Movie info

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:) ⇒ Movie

Returns a new instance of Movie.



14
15
16
17
18
19
20
# File 'lib/movlog/movie.rb', line 14

def initialize(data:)
  @imdb_id = data[:imdb_id]
  @title = data[:title]
  @year = data[:year]
  @type = data[:type]
  @poster = data[:poster]
end

Instance Attribute Details

#actorsObject (readonly)

Returns the value of attribute actors.



9
10
11
# File 'lib/movlog/movie.rb', line 9

def actors
  @actors
end

#awardsObject (readonly)

Returns the value of attribute awards.



9
10
11
# File 'lib/movlog/movie.rb', line 9

def awards
  @awards
end

#countryObject (readonly)

Returns the value of attribute country.



10
11
12
# File 'lib/movlog/movie.rb', line 10

def country
  @country
end

#directorObject (readonly)

Returns the value of attribute director.



9
10
11
# File 'lib/movlog/movie.rb', line 9

def director
  @director
end

#genreObject (readonly)

Returns the value of attribute genre.



8
9
10
# File 'lib/movlog/movie.rb', line 8

def genre
  @genre
end

#imdb_idObject (readonly)

Returns the value of attribute imdb_id.



7
8
9
# File 'lib/movlog/movie.rb', line 7

def imdb_id
  @imdb_id
end

#languageObject (readonly)

Returns the value of attribute language.



10
11
12
# File 'lib/movlog/movie.rb', line 10

def language
  @language
end

#locationObject (readonly)

Returns the value of attribute location.



12
13
14
# File 'lib/movlog/movie.rb', line 12

def location
  @location
end

#plotObject (readonly)

Returns the value of attribute plot.



8
9
10
# File 'lib/movlog/movie.rb', line 8

def plot
  @plot
end

#posterObject (readonly)

Returns the value of attribute poster.



7
8
9
# File 'lib/movlog/movie.rb', line 7

def poster
  @poster
end

#ratingObject (readonly)

Returns the value of attribute rating.



8
9
10
# File 'lib/movlog/movie.rb', line 8

def rating
  @rating
end

#releasedObject (readonly)

Returns the value of attribute released.



7
8
9
# File 'lib/movlog/movie.rb', line 7

def released
  @released
end

#responseObject (readonly)

Returns the value of attribute response.



11
12
13
# File 'lib/movlog/movie.rb', line 11

def response
  @response
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



8
9
10
# File 'lib/movlog/movie.rb', line 8

def runtime
  @runtime
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/movlog/movie.rb', line 7

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/movlog/movie.rb', line 7

def type
  @type
end

#yearObject (readonly)

Returns the value of attribute year.



7
8
9
# File 'lib/movlog/movie.rb', line 7

def year
  @year
end

Class Method Details

.find(data) ⇒ Object



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

def self.find(data)
  new(data: data)
end

Instance Method Details

#get_detailsObject



31
32
33
34
# File 'lib/movlog/movie.rb', line 31

def get_details
  movie_details = OmdbApi.movie_info(@title)
  parse_details(details: movie_details)
end

#get_locationObject



26
27
28
29
# File 'lib/movlog/movie.rb', line 26

def get_location
  return @location if @location
  @location = OmdbApi.location(@imdb_id)
end

#parse_details(details:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/movlog/movie.rb', line 36

def parse_details(details:)
  @rating = details['imdbRating']
  @plot = details['Plot']
  @runtime = details['Runtime']
  @awards = details['Awards']
  @director = details['Director']
  @actors = details['Actors']
  @country = details['Country']
  @language = details['Language']
  @released = details['Released']
  @genre = details['Genre']
end