Sha256: 14240ca0a970c85bbaef45aadfdb313a985b12c1a1bdc6e6f52507f8edae513e

Contents?: true

Size: 501 Bytes

Versions: 13

Compression:

Stored size: 501 Bytes

Contents

require 'uri_template'

module Spyke
  class Path
    def initialize(uri_template, params = {})
      @uri_template = URITemplate.new(:colon, uri_template)
      @params = params
    end

    def join(other_path)
      self.class.new File.join(path, other_path.to_s), @params
    end

    def to_s
      path
    end

    def variables
      @variables ||= @uri_template.variables.map(&:to_sym)
    end

    private

      def path
        @uri_template.expand(@params).chomp('/')
      end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spyke-1.6.0 lib/spyke/path.rb
spyke-1.5.0 lib/spyke/path.rb
spyke-1.4.1 lib/spyke/path.rb
spyke-1.4.0 lib/spyke/path.rb
spyke-1.3.0 lib/spyke/path.rb
spyke-1.2.1 lib/spyke/path.rb
spyke-1.2.0 lib/spyke/path.rb
spyke-1.1.2 lib/spyke/path.rb
spyke-1.1.1 lib/spyke/path.rb
spyke-1.1.0 lib/spyke/path.rb
spyke-1.0.2 lib/spyke/path.rb
spyke-1.0.1 lib/spyke/path.rb
spyke-1.0.0 lib/spyke/path.rb