Class: OodAppkit::Url

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

Overview

A generic class used to handle URLs for an app

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: '', base_url: '/', template: '{/url*}/') ⇒ Url

Returns a new instance of Url.

Parameters:

  • title (#to_s) (defaults to: '')

    the title of the URL

  • base_url (#to_s) (defaults to: '/')

    the base URL used to access this app

  • template (#to_s) (defaults to: '{/url*}/')

    the template used to generate URLs for this app

See Also:



14
15
16
17
18
# File 'lib/ood_appkit/url.rb', line 14

def initialize(title: '', base_url: '/', template: '{/url*}/')
  @title = title.to_s
  @template = Addressable::Template.new template.to_s
  @base_url = parse_url_segments(base_url.to_s)
end

Instance Attribute Details

#titleString (readonly)

The title for this URL

Returns:

  • (String)

    the title of the URL



8
9
10
# File 'lib/ood_appkit/url.rb', line 8

def title
  @title
end

Instance Method Details

#urlAddressable::URI

URL to access this app

Returns:

  • (Addressable::URI)

    the url used to access the app



22
23
24
# File 'lib/ood_appkit/url.rb', line 22

def url
  @template.expand url: @base_url
end