class OodAppkit::Url

A generic class used to handle URLs for an app

Attributes

title[R]

The title for this URL @return [String] the title of the URL

Public Class Methods

new(title: '', base_url: '/', template: '{/url*}/') click to toggle source

@param title [#to_s] the title of the URL @param base_url [#to_s] the base URL used to access this app @param template [#to_s] the template used to generate URLs for this app @see www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format

# 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

Public Instance Methods

url() click to toggle source

URL to access this app @return [Addressable::URI] the url used to access the app

# File lib/ood_appkit/url.rb, line 22
def url
  @template.expand url: @base_url
end

Private Instance Methods

parse_url_segments(url) click to toggle source

Parse URL segments into an array

# File lib/ood_appkit/url.rb, line 28
def parse_url_segments(url)
  url.split('/').reject(&:empty?)
end