Class: OodAppkit::EditorUrl
- Inherits:
-
Object
- Object
- OodAppkit::EditorUrl
- Defined in:
- lib/ood_appkit/editor_url.rb
Overview
A class used to handle URLs for the system file Editor app.
Instance Attribute Summary collapse
-
#title ⇒ String
readonly
The title for this URL.
Instance Method Summary collapse
-
#edit(path: '') ⇒ Addressable::URI
URL to access this app’s file editor API for a given absolute file path.
-
#initialize(title: '', base_url: '/', edit_url: '/edit', template: '{/url*}{+path}') ⇒ EditorUrl
constructor
A new instance of EditorUrl.
-
#url ⇒ Addressable::URI
URL to access this app.
Constructor Details
#initialize(title: '', base_url: '/', edit_url: '/edit', template: '{/url*}{+path}') ⇒ EditorUrl
Returns a new instance of EditorUrl.
13 14 15 16 17 18 19 20 |
# File 'lib/ood_appkit/editor_url.rb', line 13 def initialize(title: '', base_url: '/', edit_url: '/edit', template: '{/url*}{+path}') @title = title @template = Addressable::Template.new template # Break up into arrays of strings @base_url = base_url.split('/').reject(&:empty?) @edit_url = edit_url.split('/').reject(&:empty?) end |
Instance Attribute Details
#title ⇒ String (readonly)
The title for this URL
6 7 8 |
# File 'lib/ood_appkit/editor_url.rb', line 6 def title @title end |
Instance Method Details
#edit(path: '') ⇒ Addressable::URI
URL to access this app’s file editor API for a given absolute file path
31 32 33 |
# File 'lib/ood_appkit/editor_url.rb', line 31 def edit(path: '') @template. url: @base_url + @edit_url, path: path.to_s end |
#url ⇒ Addressable::URI
URL to access this app
24 25 26 |
# File 'lib/ood_appkit/editor_url.rb', line 24 def url @template. url: @base_url end |