Class: Renmov::BasicRenamer
- Inherits:
-
Object
- Object
- Renmov::BasicRenamer
- Defined in:
- lib/renmov/basic_renamer.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #get_episode ⇒ Object
- #get_format ⇒ Object
- #get_season ⇒ Object
- #get_title ⇒ Object
-
#initialize(filename) ⇒ BasicRenamer
constructor
A new instance of BasicRenamer.
- #rename ⇒ Object
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
#filename ⇒ Object (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_episode ⇒ Object
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_format ⇒ Object
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_season ⇒ Object
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_title ⇒ Object
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 |
#rename ⇒ Object
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 |