class MountableFileServer::UniqueIdentifier

Attributes

filename[R]
type[R]

Public Class Methods

generate_for(type, extension) click to toggle source
# File lib/mountable_file_server/unique_identifier.rb, line 20
def self.generate_for(type, extension)
  new "#{type}-#{SecureRandom.hex}#{extension}"
end
new(string) click to toggle source
Calls superclass method
# File lib/mountable_file_server/unique_identifier.rb, line 10
def initialize(string)
  raise MalformedIdentifier.new unless /(\w+)-(.+)$/.match(string)

  @type, @filename = /(\w+)-(.+)$/.match(string).captures

  raise UnknownType.new(type) unless known_type?

  super.freeze
end

Public Instance Methods

public?() click to toggle source
# File lib/mountable_file_server/unique_identifier.rb, line 24
def public?
  type == 'public'
end

Private Instance Methods

known_type?() click to toggle source
# File lib/mountable_file_server/unique_identifier.rb, line 29
def known_type?
  ['public', 'private'].include?(type)
end