Class: EhbrsRubyUtils::Videos::Series::Rename::File

Inherits:
LineResult
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/videos/series/rename/file.rb,
lib/ehbrs_ruby_utils/videos/series/rename/file/options.rb,
lib/ehbrs_ruby_utils/videos/series/rename/file/renamer.rb,
lib/ehbrs_ruby_utils/videos/series/rename/file/basename_parser.rb

Defined Under Namespace

Modules: BasenameParser Classes: Options, Renamer

Instance Method Summary collapse

Methods inherited from LineResult

#show

Instance Method Details

#current_nameString

Returns:

  • (String)


20
21
22
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 20

def current_name
  file.basename.to_path
end

#dirnamePathname

Returns:

  • (Pathname)


41
42
43
44
45
46
47
48
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 41

def dirname
  d = file
  until d.root?
    d = d.dirname
    return d unless d.basename.to_path.starts_with?('_')
  end
  raise "series_dirname not found for #{file.to_path}"
end

#episodeObject



34
35
36
37
38
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 34

def episode
  return '??' if parse.blank?

  parse.fetch(:e)
end

#line_outObject



50
51
52
53
54
55
56
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 50

def line_out
  "#{episode.green}: " + if new_name == current_name
                           current_name.light_black
                         else
                           "#{new_name} <= #{current_name}"
                         end
end

#new_nameObject



58
59
60
61
62
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 58

def new_name
  return "#{kernel}-s#{parse[:s]}e#{new_name_episodes}#{extension}" if parse.present?

  current_name
end

#renameObject



24
25
26
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 24

def rename
  EhbrsRubyUtils::Videos::Series::Rename::File::Renamer.new(self).perform
end

#seasonObject



28
29
30
31
32
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file.rb', line 28

def season
  return '??' if parse.blank?

  parse.fetch(:s)
end