Sha256: 2c95732829bbd4cc188d5fa22402de51ffbcde76ef71882254c971a38724013b

Contents?: true

Size: 442 Bytes

Versions: 1

Compression:

Stored size: 442 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)
    end

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

    def build
      @elements.join
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url_generator-0.1.2 lib/url_generator.rb