Class: NowPlaying::Movie

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, url = nil) ⇒ Movie

Returns a new instance of Movie.



4
5
6
7
# File 'lib/now_playing/movie.rb', line 4

def initialize(name = nil, url = nil)
  @name = name
  @url = url
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/now_playing/movie.rb', line 2

def name
  @name
end

#starsObject

Returns the value of attribute stars.



2
3
4
# File 'lib/now_playing/movie.rb', line 2

def stars
  @stars
end

#summaryObject

Returns the value of attribute summary.



2
3
4
# File 'lib/now_playing/movie.rb', line 2

def summary
  @summary
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/now_playing/movie.rb', line 2

def url
  @url
end

Class Method Details

.allObject



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

def self.all
  @@all ||= scrape_now_playing
end

.find(id) ⇒ Object



13
14
15
# File 'lib/now_playing/movie.rb', line 13

def self.find(id)
  self.all[id-1]
end

.find_by_name(name) ⇒ Object



17
18
19
20
21
22
# File 'lib/now_playing/movie.rb', line 17

def self.find_by_name(name)
  self.all.detect do |m|
    m.name.downcase.strip == name.downcase.strip ||
    m.name.split("(").first.strip.downcase == name.downcase.strip
  end
end