Sha256: cb14794ba187ced4defa393a76c6a3ce056d79cd4542677470205a8668efc675

Contents?: true

Size: 887 Bytes

Versions: 8

Compression:

Stored size: 887 Bytes

Contents

module OodAppkit
  # A class used to handle URLs for the publicly available assets.
  class PublicUrl
    # The title for this URL
    # @return [String] the title of the URL
    attr_reader :title

    # @param title [String] the title of the URL
    # @param base_url [String] the base URL used to access this app
    # @param template [String] 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
      @template = Addressable::Template.new template

      # Break up into arrays of strings
      @base_url = base_url.split('/').reject(&:empty?)
    end

    # URL to access this app
    # @return [Addressable::URI] the url used to access the app
    def url
      @template.expand url: @base_url
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ood_appkit-0.2.6 lib/ood_appkit/public_url.rb
ood_appkit-0.2.5 lib/ood_appkit/public_url.rb
ood_appkit-0.2.3 lib/ood_appkit/public_url.rb
ood_appkit-0.2.2 lib/ood_appkit/public_url.rb
ood_appkit-0.2.1 lib/ood_appkit/public_url.rb
ood_appkit-0.1.0 lib/ood_appkit/public_url.rb
ood_appkit-0.0.3 lib/ood_appkit/public_url.rb
ood_appkit-0.0.2 lib/ood_appkit/public_url.rb