Class: MountableFileServer::URI
- Inherits:
-
String
- Object
- String
- MountableFileServer::URI
- Defined in:
- lib/mountable_file_server/uri.rb
Instance Method Summary collapse
- #decoded_processing_instructions ⇒ Object
- #encoded_processing_instructions ⇒ Object
- #filename ⇒ Object
-
#initialize(string) ⇒ URI
constructor
A new instance of URI.
- #resize(instructions) ⇒ Object
- #uid ⇒ Object
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_instructions ⇒ Object
19 20 21 |
# File 'lib/mountable_file_server/uri.rb', line 19 def decoded_processing_instructions UrlSafeBase64.decode64 encoded_processing_instructions end |
#encoded_processing_instructions ⇒ Object
15 16 17 |
# File 'lib/mountable_file_server/uri.rb', line 15 def encoded_processing_instructions /\.(\w+)\./.match(filename).captures.first end |
#filename ⇒ Object
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 |
#uid ⇒ Object
11 12 13 |
# File 'lib/mountable_file_server/uri.rb', line 11 def uid UniqueIdentifier.new filename end |