Sha256: e616d7dea6a1fb6cb1c73d6bcdb3e5c29d5feb102a3c547cd05f9180526c8809
Contents?: true
Size: 989 Bytes
Versions: 18
Compression:
Stored size: 989 Bytes
Contents
require 'addressable' module OodAppkit # A generic class used to handle URLs for an app class Url # The title for this URL # @return [String] the title of the URL attr_reader :title # @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 https://www.rfc-editor.org/rfc/rfc6570.txt RFC describing template format 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 # URL to access this app # @return [Addressable::URI] the url used to access the app def url @template.expand url: @base_url end private # Parse URL segments into an array def parse_url_segments(url) url.split('/').reject(&:empty?) end end end
Version data entries
18 entries across 18 versions & 1 rubygems