Class: OodAppkit::FilesUrl
- Inherits:
-
Object
- Object
- OodAppkit::FilesUrl
- Defined in:
- lib/ood_appkit/files_url.rb
Overview
A class used to handle URLs for the system Files app.
Instance Attribute Summary collapse
-
#title ⇒ String
readonly
The title for this URL.
Instance Method Summary collapse
-
#api(path: '') ⇒ Addressable::URI
URL to access this app’s API for a given absolute file path.
-
#initialize(title: '', base_url: '/', fs_url: '/fs', api_url: '/api/v1/fs', template: '{/url*}{+path}') ⇒ FilesUrl
constructor
A new instance of FilesUrl.
-
#url(path: '') ⇒ Addressable::URI
URL to access this app for a given absolute file path.
Constructor Details
#initialize(title: '', base_url: '/', fs_url: '/fs', api_url: '/api/v1/fs', template: '{/url*}{+path}') ⇒ FilesUrl
Returns a new instance of FilesUrl.
14 15 16 17 18 19 20 21 22 |
# File 'lib/ood_appkit/files_url.rb', line 14 def initialize(title: '', base_url: '/', fs_url: '/fs', api_url: '/api/v1/fs', template: '{/url*}{+path}') @title = title @template = Addressable::Template.new template # Break up into arrays of strings @base_url = base_url.split('/').reject(&:empty?) @fs_url = fs_url.split('/').reject(&:empty?) @api_url = api_url.split('/').reject(&:empty?) end |
Instance Attribute Details
#title ⇒ String (readonly)
The title for this URL
6 7 8 |
# File 'lib/ood_appkit/files_url.rb', line 6 def title @title end |
Instance Method Details
#api(path: '') ⇒ Addressable::URI
URL to access this app’s API for a given absolute file path
34 35 36 |
# File 'lib/ood_appkit/files_url.rb', line 34 def api(path: '') @template. url: @base_url + @api_url, path: path.to_s end |
#url(path: '') ⇒ Addressable::URI
URL to access this app for a given absolute file path
27 28 29 |
# File 'lib/ood_appkit/files_url.rb', line 27 def url(path: '') @template. url: @base_url + @fs_url, path: path.to_s end |