Class: Torganiser::EpisodeFile

Inherits:
Object
  • Object
show all
Defined in:
lib/torganiser/episode_file.rb

Overview

Models a file that contains a single episode of a TV series. Attempts to extract episode data, based on the filename.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ EpisodeFile

Returns a new instance of EpisodeFile.



7
8
9
# File 'lib/torganiser/episode_file.rb', line 7

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/torganiser/episode_file.rb', line 5

def file
  @file
end

Instance Method Details

#basenameObject



11
12
13
# File 'lib/torganiser/episode_file.rb', line 11

def basename
  @basename ||= File.basename(@file)
end

#episodeObject



19
20
21
# File 'lib/torganiser/episode_file.rb', line 19

def episode
  @episode ||= episode_info[:episode].to_i
end

#seasonObject



15
16
17
# File 'lib/torganiser/episode_file.rb', line 15

def season
  @season ||= episode_info[:season].to_i
end

#seriesObject



23
24
25
26
27
28
29
# File 'lib/torganiser/episode_file.rb', line 23

def series
  @series ||= begin
    year = episode_info[:year]
    year = year.to_i if year
    Series.new(series_name, year: year)
  end
end