Sha256: 6261c1d6ce3abdb278b85df722fd90172d0b0baccb6eeefcd40d3687cfc21a51

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module OodAppkit
  module Urls
    # A class used to handle URLs for the system file Editor app.
    class Editor < Url
      # @param (see Url#initialize)
      # @param edit_url [#to_s] the URL used to request the file editor api
      def initialize(edit_url: '/edit', template: '{/url*}{/fs}{+path}', **kwargs)
        super(template: template, **kwargs)
        @edit_url = parse_url_segments(edit_url.to_s)
      end

      # URL to access this app's file editor API for a given absolute file path
      # @param opts [#to_h] the available options for this method
      # @option opts [#to_s, nil] :path ("") The absolute path to the file on
      #   the filesystem
      # @option opts [#to_s, nil] :fs ("") The filesystem for the path
      # @return [Addressable::URI] absolute url to access path in file editor
      #   api
      def edit(opts = {})
        opts = opts.to_h.compact.symbolize_keys

        path = opts.fetch(:path, "").to_s
        fs = opts.fetch(:fs, "fs").to_s
        @template.expand url: @base_url + @edit_url, fs: fs, path: path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ood_appkit-2.1.4 lib/ood_appkit/urls/editor.rb
ood_appkit-2.1.1 lib/ood_appkit/urls/editor.rb