Class: Moviesort::TVShow

Inherits:
Object
  • Object
show all
Defined in:
lib/moviesort/tv_show.rb

Defined Under Namespace

Classes: Parser

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, show, season, episode) ⇒ TVShow

Returns a new instance of TVShow.



7
8
9
10
11
12
# File 'lib/moviesort/tv_show.rb', line 7

def initialize(filename, show, season, episode)
  @show = show
  @season = season
  @episode = episode
  @extension = File.extname(filename)
end

Instance Attribute Details

#episodeObject (readonly)

Returns the value of attribute episode.



5
6
7
# File 'lib/moviesort/tv_show.rb', line 5

def episode
  @episode
end

#seasonObject (readonly)

Returns the value of attribute season.



5
6
7
# File 'lib/moviesort/tv_show.rb', line 5

def season
  @season
end

#showObject (readonly)

Returns the value of attribute show.



5
6
7
# File 'lib/moviesort/tv_show.rb', line 5

def show
  @show
end

Class Method Details

.parse(filename) ⇒ Object



14
15
16
17
18
19
# File 'lib/moviesort/tv_show.rb', line 14

def self.parse(filename)
  parser = Parser.new(filename)
  if components = parser.parse
    new(filename, *components)
  end
end

Instance Method Details

#target_filenameObject



25
26
27
# File 'lib/moviesort/tv_show.rb', line 25

def target_filename
  "#{@show.gsub(/\W/, '.')}.S%.2iE%.2i#{@extension}" % [season, episode]
end

#target_pathObject



21
22
23
# File 'lib/moviesort/tv_show.rb', line 21

def target_path
  Pathname.new(File.join(show, "Season #{season}"))
end