module MovieMasher::Path

add and strip slashes from start and/or end of string

Constants

SLASH

Public Class Methods

add_slash_end(s) click to toggle source
# File lib/util/path.rb, line 9
def self.add_slash_end(s)
  s ||= ''
  s = "#{s}#{SLASH}" unless s.end_with?(SLASH)
  s
end
add_slash_start(s) click to toggle source
# File lib/util/path.rb, line 14
def self.add_slash_start(s)
  s ||= ''
  s = "#{SLASH}#{s}" unless s.start_with?(SLASH)
  s
end
add_slashes(s) click to toggle source
# File lib/util/path.rb, line 6
def self.add_slashes(s)
  add_slash_start(add_slash_end(s))
end
concat(s1, s2) click to toggle source
# File lib/util/path.rb, line 19
def self.concat(s1, s2)
  s1 ||= ''
  s2 ||= ''
  if s1.empty? || s2.empty?
    s1 += s2
  else
    s1 = add_slash_end(s1) + strip_slash_start(s2)
  end
  s1
end
strip_slash_end(s) click to toggle source
# File lib/util/path.rb, line 32
def self.strip_slash_end(s)
  s ||= ''
  s = s[0..-2] if s.end_with?(SLASH)
  s
end
strip_slash_start(s) click to toggle source
# File lib/util/path.rb, line 37
def self.strip_slash_start(s)
  s ||= ''
  s = s[1..-1] if s.start_with?(SLASH)
  s
end
strip_slashes(s) click to toggle source
# File lib/util/path.rb, line 29
def self.strip_slashes(s)
  strip_slash_start(strip_slash_end(s))
end