lib/movie-renamer.rb in movie-renamer-0.0.4 vs lib/movie-renamer.rb in movie-renamer-0.0.5

- old
+ new

@@ -1,9 +1,6 @@ #!/usr/bin/ruby -# -# -# require 'imdb' module MovieRenamer @@ -18,16 +15,17 @@ class Movie - def initialize(filename,year = '',director = '',title = '',part = '',imdb = nil) - @year = year - @director = director - @title = title - @part = part - @imdb = imdb + def initialize(filename,opts={}) + opts = { year: '', director: '', title: '', part: '', imdb: ''}.merge(opts) + @year = opts[:year] + @director = opts[:director] + @title = opts[:title] + @part = opts[:part] + @imdb = opts[:imdb] @filename = filename end attr_accessor :year, :director, :title, :part, :imdb, :filename @@ -77,10 +75,10 @@ # returns the movie object def MovieRenamer::readMovie(filename) # TODO insert logic here filename = File.basename(filename) title = File.basename(filename,'.*') - return Movie.new(filename,'','', title) + return Movie.new(filename,:title => title) end # rename a movie according to movie data # and moves it to the new path in filesystem def MovieRenamer::renameMovie(movie,newpath = NEWPATH)