Sha256: 5bf3cc38b86c0f4d870f4c31277fce4f33783500eb1833515b25ff16c5963725
Contents?: true
Size: 1.35 KB
Versions: 27
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true module Appydave module Tools # Project, channel, and file name management module NameManager # Parses and generates project names for Appydave video projects class ProjectName include Appydave::Tools::Configuration::Configurable attr_accessor :sequence, :project_name attr_reader :channel_code def initialize(file_name) parse_file_name(file_name) end def generate_name if channel_code "#{sequence}-#{channel_code}-#{project_name}" else "#{sequence}-#{project_name}" end.downcase end def channel_code=(code) @channel_code = (code if config.channels.code?(code)) end private def parse_file_name(file_name) file_name = File.basename(file_name, File.extname(file_name)) parts = file_name.split('-') length = parts.length @sequence = part(parts, 0) code = part(parts, 1) if config.channels.code?(code) @channel_code = code @project_name = parts[2..length].join('-') else @project_name = parts[1..length].join('-') end end def part(parts, index) parts[index] if parts.length > index end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems