Class: Movie

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_name, attributes = {}) ⇒ Movie

Returns a new instance of Movie.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/movie.rb', line 9

def initialize(raw_name, attributes = {})
  @raw_name = raw_name.gsub(/\.|\_/,' ')
  attributes.each { |k,v| self.send("#{k}=", v) }
  @srt, @tags = [], []
  
  # for info set with nzbs title
  if name && year && score
    @info_get_from_title = true
  end
  
  set_name
  set_year
  set_format
  set_source
  set_sound
  set_srt
  set_lang
  set_encoding
  set_tags
  
  set_imdb_id
  set_data_from_imdb unless path || @info_get_from_title
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



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

def age
  @age
end

#encodingObject

Returns the value of attribute encoding.



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

def encoding
  @encoding
end

#formatObject

Returns the value of attribute format.



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

def format
  @format
end

#imdb_idObject

Returns the value of attribute imdb_id.



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

def imdb_id
  @imdb_id
end

#imdb_link=(value) ⇒ Object

Sets the attribute imdb_link

Parameters:

  • value

    the value to set the attribute imdb_link to.



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

def imdb_link=(value)
  @imdb_link = value
end

#langObject

Returns the value of attribute lang.



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

def lang
  @lang
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#nfoObject

Returns the value of attribute nfo.



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

def nfo
  @nfo
end

Returns the value of attribute nzb_link.



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

def nzb_link
  @nzb_link
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#scoreObject

Returns the value of attribute score.



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

def score
  @score
end

#soundObject

Returns the value of attribute sound.



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

def sound
  @sound
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#srtObject

Returns the value of attribute srt.



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

def srt
  @srt
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#yearObject

Returns the value of attribute year.



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

def year
  @year
end

Instance Method Details

#<=>(other_movie) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/movie.rb', line 41

def <=>(other_movie)
  if imdb_id && other_movie.imdb_id
    imdb_id <=> other_movie.imdb_id
  else
    "#{name} #{year}".downcase <=> "#{other_movie.name} #{other_movie.year}".downcase
  end
end

#dirnameObject



37
38
39
# File 'lib/movie.rb', line 37

def dirname
  "#{name} (#{year}) #{tags.join(' ')} #{format} #{source} #{sound} #{encoding} #{lang} {#{imdb_id}} [#{srt.join(',')}]".gsub(/\s+|\//,' ')
end