Class: Renmov::BasicRenamer

Inherits:
Object
  • Object
show all
Defined in:
lib/renmov/basic_renamer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ BasicRenamer

Returns a new instance of BasicRenamer.



5
6
7
# File 'lib/renmov/basic_renamer.rb', line 5

def initialize(filename)
  @filename = filename.downcase
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/renmov/basic_renamer.rb', line 3

def filename
  @filename
end

Instance Method Details

#get_episodeObject



33
34
35
36
37
38
# File 'lib/renmov/basic_renamer.rb', line 33

def get_episode
  episode = filename.dup
  episode.gsub!(/.*\.s\d\de(\d\d).*/, '\1')

  episode 
end

#get_formatObject



40
41
42
43
44
45
# File 'lib/renmov/basic_renamer.rb', line 40

def get_format
  format = filename.dup
  format.gsub!(/.*\.(.*)\z/, '\1')

  format
end

#get_seasonObject



26
27
28
29
30
31
# File 'lib/renmov/basic_renamer.rb', line 26

def get_season
  season = filename.dup
  season.gsub!(/.*\.s(\d\d).*/, '\1')

  season
end

#get_titleObject



18
19
20
21
22
23
24
# File 'lib/renmov/basic_renamer.rb', line 18

def get_title
  title = filename.dup
  title.gsub!(/\Athe\./, '')
  title.gsub!(/(\.20\d\d)?\.s\d\de\d\d.*/, '')

  title
end

#renameObject



9
10
11
12
13
14
15
16
# File 'lib/renmov/basic_renamer.rb', line 9

def rename
  title   = get_title
  season  = get_season
  episode = get_episode
  format  = get_format

  "#{title}.s#{season}e#{episode}.#{format}"
end