Class: AppleTrailers::Movie

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Movie

Returns a new instance of Movie.



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

def initialize(options)
  options.each { |key, value| instance_variable_set("@"+key.to_s, value)}
end

Instance Attribute Details

#actorsObject

Returns the value of attribute actors.



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

def actors
  @actors
end

#directorsObject

Returns the value of attribute directors.



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

def directors
  @directors
end

#genreObject

Returns the value of attribute genre.



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

def genre
  @genre
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#moviesiteObject

Returns the value of attribute moviesite.



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

def moviesite
  @moviesite
end

#ratingObject

Returns the value of attribute rating.



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

def rating
  @rating
end

#studioObject

Returns the value of attribute studio.



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

def studio
  @studio
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#descriptionObject



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

def description
  doc = Nokogiri::HTML(Net::HTTP.get(URI(["http://trailers.apple.com", @location].join(''))))
  doc.at('meta[@name="Description"]/@content').value
end

#trailersObject



16
17
18
19
# File 'lib/apple_trailers/movie.rb', line 16

def trailers
  doc = Nokogiri::HTML(Net::HTTP.get(URI(["http://trailers.apple.com", @location, "includes/playlists/web.inc"].join(''))))
  doc.css('.trailer').count > 1 ? get_multiple_trailers(doc) : get_single_trailer(doc)
end