Class: MountableFileServer::URI

Inherits:
String
  • Object
show all
Defined in:
lib/mountable_file_server/uri.rb

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ URI

Returns a new instance of URI.



7
8
9
# File 'lib/mountable_file_server/uri.rb', line 7

def initialize(string)
  super.freeze
end

Instance Method Details

#decoded_processing_instructionsObject



19
20
21
# File 'lib/mountable_file_server/uri.rb', line 19

def decoded_processing_instructions
  UrlSafeBase64.decode64 encoded_processing_instructions
end

#encoded_processing_instructionsObject



15
16
17
# File 'lib/mountable_file_server/uri.rb', line 15

def encoded_processing_instructions
  /\.(\w+)\./.match(filename).captures.first
end

#filenameObject



23
24
25
# File 'lib/mountable_file_server/uri.rb', line 23

def filename
  Pathname(::URI.parse(self).path).basename.to_s
end

#resize(instructions) ⇒ Object



27
28
29
30
31
# File 'lib/mountable_file_server/uri.rb', line 27

def resize(instructions)
  encoded_instructions = UrlSafeBase64.encode64 instructions

  URI.new self.gsub('.', ".#{encoded_instructions}.")
end

#uidObject



11
12
13
# File 'lib/mountable_file_server/uri.rb', line 11

def uid
  UniqueIdentifier.new filename
end