Class: OodAppkit::ShellUrl
- Inherits:
-
Object
- Object
- OodAppkit::ShellUrl
- Defined in:
- lib/ood_appkit/shell_url.rb
Overview
A class used to handle URLs for the system Shell app.
Instance Attribute Summary collapse
-
#title ⇒ String
readonly
The title for this URL.
Instance Method Summary collapse
-
#initialize(title: '', base_url: '/', ssh_url: '/ssh', template: '{/url*}/{host}{+path}') ⇒ ShellUrl
constructor
A new instance of ShellUrl.
-
#url(path: '', host: 'default') ⇒ Addressable::URI
URL to access this app for a given host and absolute file path.
Constructor Details
#initialize(title: '', base_url: '/', ssh_url: '/ssh', template: '{/url*}/{host}{+path}') ⇒ ShellUrl
Returns a new instance of ShellUrl.
12 13 14 15 16 17 18 19 |
# File 'lib/ood_appkit/shell_url.rb', line 12 def initialize(title: '', base_url: '/', ssh_url: '/ssh', template: '{/url*}/{host}{+path}') @title = title @template = Addressable::Template.new template # Break up into arrays of strings @base_url = base_url.split('/').reject(&:empty?) @ssh_url = ssh_url.split('/').reject(&:empty?) end |
Instance Attribute Details
#title ⇒ String (readonly)
The title for this URL
6 7 8 |
# File 'lib/ood_appkit/shell_url.rb', line 6 def title @title end |
Instance Method Details
#url(path: '', host: 'default') ⇒ Addressable::URI
URL to access this app for a given host and absolute file path
25 26 27 |
# File 'lib/ood_appkit/shell_url.rb', line 25 def url(path: '', host: 'default') @template. url: @base_url + @ssh_url, path: path.to_s, host: host end |