Class: OneRuby::Movie
- Inherits:
-
Object
- Object
- OneRuby::Movie
- Defined in:
- lib/one_ruby/movie.rb
Instance Attribute Summary collapse
-
#academy_award_nominations ⇒ Object
Returns the value of attribute academy_award_nominations.
-
#academy_award_wins ⇒ Object
Returns the value of attribute academy_award_wins.
-
#box_office_revenue_in_millions ⇒ Object
Returns the value of attribute box_office_revenue_in_millions.
-
#budget_in_millions ⇒ Object
Returns the value of attribute budget_in_millions.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rotten_tomatoes_score ⇒ Object
Returns the value of attribute rotten_tomatoes_score.
-
#runtime_in_minutes ⇒ Object
Returns the value of attribute runtime_in_minutes.
Class Method Summary collapse
Instance Attribute Details
#academy_award_nominations ⇒ Object
Returns the value of attribute academy_award_nominations.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def academy_award_nominations @academy_award_nominations end |
#academy_award_wins ⇒ Object
Returns the value of attribute academy_award_wins.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def academy_award_wins @academy_award_wins end |
#box_office_revenue_in_millions ⇒ Object
Returns the value of attribute box_office_revenue_in_millions.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def box_office_revenue_in_millions @box_office_revenue_in_millions end |
#budget_in_millions ⇒ Object
Returns the value of attribute budget_in_millions.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def budget_in_millions @budget_in_millions end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def name @name end |
#rotten_tomatoes_score ⇒ Object
Returns the value of attribute rotten_tomatoes_score.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def rotten_tomatoes_score @rotten_tomatoes_score end |
#runtime_in_minutes ⇒ Object
Returns the value of attribute runtime_in_minutes.
3 4 5 |
# File 'lib/one_ruby/movie.rb', line 3 def runtime_in_minutes @runtime_in_minutes end |
Class Method Details
.find(id) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/one_ruby/movie.rb', line 12 def self.find(id) results = OneRuby::Client.get "movie/#{id}" docs = results['docs'] if docs.empty? nil else transform(docs.first) end end |
.list ⇒ Object
6 7 8 9 10 |
# File 'lib/one_ruby/movie.rb', line 6 def self.list results = OneRuby::Client.get 'movie' movies = results['docs'] movies.map { |r| transform(r) } end |
.transform(response) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/one_ruby/movie.rb', line 22 def self.transform(response) movie = Movie.new movie.id = response['_id'] movie.name = response['name'] movie.runtime_in_minutes = response['runtimeInMinutes'] movie.budget_in_millions = response['budgetInMillions'] movie.box_office_revenue_in_millions = response['boxOfficeRevenueInMillions'] movie.academy_award_nominations = response['academyAwardNominations'] movie.academy_award_wins = response['academyAwardWins'] movie.rotten_tomatoes_score = response['rottenTomatoesScore'] movie end |