class Filename

Constants

VERSION

Public Class Methods

new(base, *extensions) click to toggle source
# File lib/filename.rb, line 8
def initialize(base, *extensions)
  @base, @extensions = clean(base), clean(extensions)
end
parse(value) click to toggle source
# File lib/filename.rb, line 4
def self.parse(value)
  new *value.to_s.split('.')
end

Public Instance Methods

prefix(*values, seperator: '_') click to toggle source
# File lib/filename.rb, line 16
def prefix(*values, seperator: '_')
  @base.unshift(clean(values).push('').join(seperator)) && self
end
suffix(*values, seperator: '_') click to toggle source
# File lib/filename.rb, line 12
def suffix(*values, seperator: '_')
  @base.push(clean(values).unshift('').join(seperator)) && self
end
to_path()
Alias for: to_s
to_s() click to toggle source
# File lib/filename.rb, line 20
def to_s
  @extensions.unshift(@base.join).join('.')
end
Also aliased as: to_path

Private Instance Methods

clean(input) click to toggle source
# File lib/filename.rb, line 28
def clean(input)
  Array(input).flatten.map { |v| v.to_s.strip }.reject(&:empty?)
end