Class: Movlog::Movie
- Inherits:
-
Object
- Object
- Movlog::Movie
- Defined in:
- lib/movlog/movie.rb
Overview
Movie info
Instance Attribute Summary collapse
-
#actors ⇒ Object
readonly
Returns the value of attribute actors.
-
#awards ⇒ Object
readonly
Returns the value of attribute awards.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#director ⇒ Object
readonly
Returns the value of attribute director.
-
#genre ⇒ Object
readonly
Returns the value of attribute genre.
-
#imdb_id ⇒ Object
readonly
Returns the value of attribute imdb_id.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#plot ⇒ Object
readonly
Returns the value of attribute plot.
-
#poster ⇒ Object
readonly
Returns the value of attribute poster.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#released ⇒ Object
readonly
Returns the value of attribute released.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
- #get_details ⇒ Object
- #get_location ⇒ Object
-
#initialize(data:) ⇒ Movie
constructor
A new instance of Movie.
- #parse_details(details:) ⇒ Object
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
#actors ⇒ Object (readonly)
Returns the value of attribute actors.
9 10 11 |
# File 'lib/movlog/movie.rb', line 9 def actors @actors end |
#awards ⇒ Object (readonly)
Returns the value of attribute awards.
9 10 11 |
# File 'lib/movlog/movie.rb', line 9 def awards @awards end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
10 11 12 |
# File 'lib/movlog/movie.rb', line 10 def country @country end |
#director ⇒ Object (readonly)
Returns the value of attribute director.
9 10 11 |
# File 'lib/movlog/movie.rb', line 9 def director @director end |
#genre ⇒ Object (readonly)
Returns the value of attribute genre.
8 9 10 |
# File 'lib/movlog/movie.rb', line 8 def genre @genre end |
#imdb_id ⇒ Object (readonly)
Returns the value of attribute imdb_id.
7 8 9 |
# File 'lib/movlog/movie.rb', line 7 def imdb_id @imdb_id end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
10 11 12 |
# File 'lib/movlog/movie.rb', line 10 def language @language end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
12 13 14 |
# File 'lib/movlog/movie.rb', line 12 def location @location end |
#plot ⇒ Object (readonly)
Returns the value of attribute plot.
8 9 10 |
# File 'lib/movlog/movie.rb', line 8 def plot @plot end |
#poster ⇒ Object (readonly)
Returns the value of attribute poster.
7 8 9 |
# File 'lib/movlog/movie.rb', line 7 def poster @poster end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
8 9 10 |
# File 'lib/movlog/movie.rb', line 8 def @rating end |
#released ⇒ Object (readonly)
Returns the value of attribute released.
7 8 9 |
# File 'lib/movlog/movie.rb', line 7 def released @released end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
11 12 13 |
# File 'lib/movlog/movie.rb', line 11 def response @response end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
8 9 10 |
# File 'lib/movlog/movie.rb', line 8 def runtime @runtime end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/movlog/movie.rb', line 7 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/movlog/movie.rb', line 7 def type @type end |
#year ⇒ Object (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_details ⇒ Object
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_location ⇒ Object
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 |