Module: EhbrsRubyUtils::Videos::Series::Rename::File::BasenameParser
- Defined in:
- lib/ehbrs_ruby_utils/videos/series/rename/file/basename_parser.rb
Constant Summary collapse
- FORMATS =
[{ format: /(\d+)(\d{2})(\d{2})/i, build: ->(m) { { s: padding(m[1]), e: "#{padding(m[2])}-#{padding(m[3])}" } } }, { format: /s(\d+)e(\d+)-(\d+)/i, build: ->(m) { { s: padding(m[1]), e: "#{padding(m[2])}-#{padding(m[3])}" } } }, { format: /(\d{1,2})\s*[^\d]\s*(\d{2})/i, build: ->(m) { { s: padding(m[1]), e: padding(m[2]) } } }, { format: /(\d+)(\d{2})/i, build: ->(m) { { s: padding(m[1]), e: padding(m[2]) } } }, { format: /(\d{2})/i, build: ->(m) { { s: padding(1), e: padding(m[1]) } } }].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.padding(string) ⇒ Object
28 29 30 |
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file/basename_parser.rb', line 28 def self.padding(string) string.to_s.rjust(2, '0') end |
Instance Method Details
#parse_uncached ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/ehbrs_ruby_utils/videos/series/rename/file/basename_parser.rb', line 32 def parse_uncached FORMATS.each do |format| m = format.fetch(:format).match(current_name) return format.fetch(:build).call(m) if m end nil end |