Class: OodAppkit::ShellUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_appkit/shell_url.rb

Overview

A class used to handle URLs for the system Shell app.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: '', base_url: '/', ssh_url: '/ssh', template: '{/url*}/{host}{+path}') ⇒ ShellUrl

Returns a new instance of ShellUrl.

Parameters:

  • title (String) (defaults to: '')

    the title of the URL

  • base_url (String) (defaults to: '/')

    the base URL used to access this app

  • template (String) (defaults to: '{/url*}/{host}{+path}')

    the template used to generate URLs for this app

See Also:



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

#titleString (readonly)

The title for this URL

Returns:

  • (String)

    the title of the 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

Parameters:

  • host (String) (defaults to: 'default')

    the host the app will make an ssh connection with

  • path (String, #to_s) (defaults to: '')

    the absolute path to the directory ssh app opens up in

Returns:

  • (Addressable::URI)

    the url used to access the app



25
26
27
# File 'lib/ood_appkit/shell_url.rb', line 25

def url(path: '', host: 'default')
  @template.expand url: @base_url + @ssh_url, path: path.to_s, host: host
end