Sha256: a027c35fd96b499b988c34e5d519d7610792309b390ce2926eceed7b2d03a0d6

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

# frozen_string_literal: true

require_relative "url_generator/version"

module UrlGenerator
  class UrlGenerator
    def initialize(base_url)
      @elements = [base_url]
    end

    def append(element)
      @elements.append(element)
      self
    end

    def query(key, value)
      @elements.include?('?') ? @elements.append("&#{key}=#{value}") : @elements.append("?#{key}=#{value}")
      self
    end

    def build
      @elements.join
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url_generator-0.1.3 lib/url_generator.rb